2025-02-17 22:21:30 +01:00
|
|
|
from rest_framework.generics import ListAPIView, RetrieveAPIView
|
2025-02-12 13:23:35 +01:00
|
|
|
from rest_framework.response import Response
|
|
|
|
from rest_framework.exceptions import NotFound
|
|
|
|
from rest_framework.permissions import IsAuthenticated
|
|
|
|
|
|
|
|
from apps.archive.models import CreatorModel
|
|
|
|
|
|
|
|
from .serializers import (
|
|
|
|
CreatorListSerializer,
|
|
|
|
CreatorDetailsSerializer,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2025-02-17 22:21:30 +01:00
|
|
|
class CreatorListView(ListAPIView):
|
2025-02-12 13:23:35 +01:00
|
|
|
permission_classes = [IsAuthenticated]
|
2025-02-17 22:21:30 +01:00
|
|
|
serializer_class = CreatorListSerializer
|
2025-02-12 13:23:35 +01:00
|
|
|
|
2025-02-17 22:21:30 +01:00
|
|
|
def get_queryset(self):
|
|
|
|
user = self.request.user.userprofile
|
2025-02-12 13:23:35 +01:00
|
|
|
|
|
|
|
if user.show_mature:
|
2025-02-17 22:21:30 +01:00
|
|
|
return CreatorModel.objects.all()
|
2025-02-12 13:23:35 +01:00
|
|
|
else:
|
2025-02-17 22:21:30 +01:00
|
|
|
return CreatorModel.objects.filter(mature=False)
|
2025-02-12 13:23:35 +01:00
|
|
|
|
|
|
|
|
2025-02-17 22:21:30 +01:00
|
|
|
class CreatorDetailsView(RetrieveAPIView):
|
2025-02-12 13:23:35 +01:00
|
|
|
permission_classes = [IsAuthenticated]
|
2025-02-17 22:21:30 +01:00
|
|
|
serializer_class = CreatorDetailsSerializer
|
|
|
|
lookup_field = "creator_id"
|
2025-02-12 13:23:35 +01:00
|
|
|
|
2025-02-17 22:21:30 +01:00
|
|
|
def get_queryset(self):
|
|
|
|
user = self.request.user.userprofile
|
2025-02-12 13:23:35 +01:00
|
|
|
|
2025-02-17 22:21:30 +01:00
|
|
|
if user.show_mature:
|
|
|
|
return CreatorModel.objects.all()
|
|
|
|
else:
|
|
|
|
return CreatorModel.objects.filter(mature=False)
|