From ea4f6f84aae3e0d8719460270593eb8a70a4f97f Mon Sep 17 00:00:00 2001 From: through-your-tears Date: Sat, 6 Apr 2024 14:58:28 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D1=80=D0=B0=D0=B7=D0=BD=D1=8B=D0=B5=20activitie?= =?UTF-8?q?s=20=D0=B4=D0=BB=D1=8F=20=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/activities/views.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/activities/views.py b/src/activities/views.py index 9955153..5445e8d 100644 --- a/src/activities/views.py +++ b/src/activities/views.py @@ -1,11 +1,12 @@ from django.shortcuts import get_object_or_404 from rest_framework.generics import ListAPIView, CreateAPIView, DestroyAPIView from rest_framework.pagination import PageNumberPagination +from rest_framework.permissions import IsAuthenticated from core.permissions import IsAuthorOrReadOnly from organizations.repositories import OrganizationRepository from .repositories import PhotoRepository, FavouriteOrganizationRepository -from .serializers import PhotoSerializer, ListPhotoSerializer +from .serializers import PhotoSerializer, ListPhotoSerializer, FavouriteOrganizationSerializer # Create your views here. @@ -25,10 +26,9 @@ class PhotoListCreateAPIView(ListAPIView, CreateAPIView): serializer.save(user=self.request.user) -class FavouriteOrganizationAPIView(ListAPIView, CreateAPIView, DestroyAPIView): - - def get_queryset(self): - return FavouriteOrganizationRepository.get_filtered(user=self.request.user) +class FavouriteOrganizationAPIView(CreateAPIView, DestroyAPIView): + serializer_class = FavouriteOrganizationSerializer + permission_classes = [IsAuthenticated] def get_object(self): queryset = self.get_queryset() @@ -41,3 +41,12 @@ class FavouriteOrganizationAPIView(ListAPIView, CreateAPIView, DestroyAPIView): pass else: serializer.save(user=self.request.user, organization=self.kwargs.get('id')) + + +class FavouriteOrganizationsListAPIView(ListAPIView): + permission_classes = [IsAuthenticated] + pagination_class = PageNumberPagination + serializer_class = FavouriteOrganizationSerializer + + def get_queryset(self): + return FavouriteOrganizationRepository.get_filtered(user=self.request.user)