from typing import Type

from django.db.models import QuerySet
from rest_framework.generics import GenericAPIView
from rest_framework.permissions import AllowAny
from rest_framework.request import Request
from rest_framework.response import Response
from rest_framework.serializers import Serializer

from apps.geology.models import GalleryCategory
from apps.geology.serializers import GalleryCategorySerializer


class GalleryCategoryView(GenericAPIView):
    permission_classes = [AllowAny]
    serializer_class: Type[Serializer] = GalleryCategorySerializer

    def get_queryset(self) -> QuerySet[GalleryCategory]:
        return GalleryCategory.objects.all()

    def get(self, request: Request) -> Response:
        categories = self.get_queryset()
        serializer = self.serializer_class(categories, many=True)
        return Response(serializer.data)
