1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2024-12-22 23:42:25 +00:00

Fix membership table order

This commit is contained in:
Yohann D'ANELLO 2020-10-07 10:03:43 +02:00
parent 992cfe8e23
commit 36b8157372

View File

@ -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-")