From f6dfbb0b6c64c33b1bc581208ac2d84fa5927022 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Sun, 9 Aug 2020 19:49:11 +0200 Subject: [PATCH] Fix amount of \ in apps/activity/views.py --- apps/activity/views.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/apps/activity/views.py b/apps/activity/views.py index 6ce84185..033cec3e 100644 --- a/apps/activity/views.py +++ b/apps/activity/views.py @@ -151,14 +151,21 @@ class ActivityEntryView(LoginRequiredMixin, TemplateView): first_name=F("note__noteuser__user__first_name"), username=F("note__noteuser__user__username"), note_name=F("name"), - balance=F("note__balance"))\ - .filter(note__noteuser__isnull=False)\ - .filter( + balance=F("note__balance")) + + # Keep only users that have a note + note_qs = note_qs.filter(note__noteuser__isnull=False) + + # Keep only members + note_qs = note_qs.filter( note__noteuser__user__memberships__club=activity.attendees_club, note__noteuser__user__memberships__date_start__lte=timezone.now(), note__noteuser__user__memberships__date_end__gte=timezone.now(), - )\ - .filter(PermissionBackend.filter_queryset(self.request.user, Alias, "view")) + ) + + # Filter with permission backend + note_qs = note_qs.filter(PermissionBackend.filter_queryset(self.request.user, Alias, "view")) + if pattern: note_qs = note_qs.filter( Q(note__noteuser__user__first_name__regex=pattern)