From 36b815737286395193bf37d3304939af6205a0de Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Wed, 7 Oct 2020 10:03:43 +0200 Subject: [PATCH] Fix membership table order --- apps/member/views.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/member/views.py b/apps/member/views.py index 6aa0586c..f736f47e 100644 --- a/apps/member/views.py +++ b/apps/member/views.py @@ -159,9 +159,9 @@ class UserDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView): club_list = Membership.objects.filter(user=user, date_end__gte=date.today() - timedelta(days=15))\ .filter(PermissionBackend.filter_queryset(self.request.user, Membership, "view"))\ - .order_by("date_start", "club__name") + .order_by("club__name", "-date_start") # Display only the most recent membership - club_list = club_list.distinct("club")\ + club_list = club_list.distinct("club__name")\ if settings.DATABASES["default"]["ENGINE"] == 'django.db.backends.postgresql' else club_list membership_table = MembershipTable(data=club_list, prefix='membership-') membership_table.paginate(per_page=10, page=self.request.GET.get("membership-page", 1)) @@ -415,9 +415,9 @@ class ClubDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView): club=club, date_end__gte=date.today() - timedelta(days=15), ).filter(PermissionBackend.filter_queryset(self.request.user, Membership, "view"))\ - .order_by("date_start", "user__username") + .order_by("user__username", "-date_start") # Display only the most recent membership - club_member = club_member.distinct("user")\ + club_member = club_member.distinct("user__username")\ if settings.DATABASES["default"]["ENGINE"] == 'django.db.backends.postgresql' else club_member membership_table = MembershipTable(data=club_member, prefix="membership-")