From d247aac8f4ef69d0afda0379b0639eb15fdd6bc8 Mon Sep 17 00:00:00 2001 From: Adibov Date: Mon, 27 Nov 2023 21:21:49 +0330 Subject: [PATCH] fix(backend): fix filtering based on year in list queries --- backend/backend_api/views.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/backend/backend_api/views.py b/backend/backend_api/views.py index 0c2669a..e2a12f9 100644 --- a/backend/backend_api/views.py +++ b/backend/backend_api/views.py @@ -105,14 +105,14 @@ class WorkshopViewSet(viewsets.GenericViewSet, def list(self, request, year=None, **kwargs): if year is None: year = datetime.datetime.now().year - queryset = models.Workshop.objects.filter(year=year) - return super().list(request, queryset=queryset, **kwargs) + self.queryset = models.Workshop.objects.filter(year=year) + return super().list(request, **kwargs) def retrieve(self, request, year=None, pk=None): if year is None: year = datetime.datetime.now().year - queryset = models.Workshop.objects.filter(year=year) - return super().retrieve(request, pk=pk, queryset=queryset) + self.queryset = models.Workshop.objects.filter(year=year) + return super().retrieve(request, pk=pk) class PresentationViewSet(viewsets.GenericViewSet, @@ -124,14 +124,14 @@ class PresentationViewSet(viewsets.GenericViewSet, def list(self, request, year=None, **kwargs): if year is None: year = datetime.datetime.now().year - queryset = self.queryset.filter(year=year) - return super().list(request, queryset=queryset, **kwargs) + self.queryset = self.queryset.filter(year=year) + return super().list(request, **kwargs) def retrieve(self, request, year=None, pk=None): if year is None: year = datetime.datetime.now().year - queryset = models.Presentation.objects.filter(year=year) - return super().retrieve(request, pk=pk, queryset=queryset) + self.queryset = models.Presentation.objects.filter(year=year) + return super().retrieve(request, pk=pk) class MiscViewSet(viewsets.ViewSet):