|
7 | 7 | from django.shortcuts import redirect |
8 | 8 | from django_filters import rest_framework as filters |
9 | 9 | from rest_framework import status, permissions |
| 10 | +from rest_framework import exceptions |
10 | 11 | from rest_framework.generics import ( |
11 | 12 | GenericAPIView, |
12 | 13 | ListAPIView, |
|
20 | 21 | from rest_framework.views import APIView |
21 | 22 | from rest_framework_simplejwt.tokens import RefreshToken, TokenError |
22 | 23 |
|
| 24 | +from core.pagination import Pagination |
23 | 25 | from core.permissions import IsOwnerOrReadOnly |
24 | 26 | from events.models import Event |
25 | 27 | from events.serializers import EventsListSerializer |
|
51 | 53 | VerifyEmailSerializer, |
52 | 54 | ResendVerifyEmailSerializer, |
53 | 55 | UserProjectListSerializer, |
| 56 | + UserSubscribedProjectsSerializer, |
54 | 57 | ) |
55 | 58 | from .filters import UserFilter |
56 | 59 | from .pagination import UsersPagination |
@@ -370,3 +373,16 @@ def post(self, request, *args, **kwargs): |
370 | 373 | return Response(status=status.HTTP_200_OK) |
371 | 374 | except User.DoesNotExist: |
372 | 375 | return Response(status=status.HTTP_404_NOT_FOUND) |
| 376 | + |
| 377 | + |
| 378 | +class UserSubscribedProjectsList(ListAPIView): |
| 379 | + permission_classes = [IsAuthenticated] |
| 380 | + serializer_class = UserSubscribedProjectsSerializer |
| 381 | + pagination_class = Pagination |
| 382 | + |
| 383 | + def get_queryset(self): |
| 384 | + try: |
| 385 | + user = User.objects.get(pk=self.kwargs["pk"]) |
| 386 | + return user.subscribed_projects.all() |
| 387 | + except User.DoesNotExist: |
| 388 | + raise exceptions.NotFound |
0 commit comments