diff --git a/apps/activity/views.py b/apps/activity/views.py index ef144460..df3f00ea 100644 --- a/apps/activity/views.py +++ b/apps/activity/views.py @@ -36,9 +36,7 @@ class ActivityCreateView(ProtectQuerysetMixin, LoginRequiredMixin, CreateView): class ActivityListView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTableView): model = Activity table_class = ActivityTable - - def get_queryset(self): - return super().get_queryset().reverse() + ordering = ('-date_start',) def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) @@ -47,7 +45,9 @@ class ActivityListView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTableView upcoming_activities = Activity.objects.filter(date_end__gt=datetime.now()) context['upcoming'] = ActivityTable( - data=upcoming_activities.filter(PermissionBackend.filter_queryset(self.request.user, Activity, "view"))) + data=upcoming_activities.filter(PermissionBackend.filter_queryset(self.request.user, Activity, "view")), + prefix='upcoming-', + ) return context diff --git a/apps/permission/views.py b/apps/permission/views.py index cbd26a19..ab555c2f 100644 --- a/apps/permission/views.py +++ b/apps/permission/views.py @@ -19,7 +19,7 @@ class ProtectQuerysetMixin: """ def get_queryset(self, **kwargs): qs = super().get_queryset(**kwargs) - return qs.filter(PermissionBackend.filter_queryset(self.request.user, qs.model, "view")) + return qs.filter(PermissionBackend.filter_queryset(self.request.user, qs.model, "view")).distinct() def get_form(self, form_class=None): form = super().get_form(form_class)