from rest_framework import generics, permissions

from main import models, serializers
from utils.models import PlatformMixin


class FeaturesView(generics.ListAPIView):
    pagination_class = None
    permission_classes = (permissions.AllowAny,)
    serializer_class = serializers.SiteFeatureSerializer

    def get_queryset(self):
        return models.SiteFeature.objects\
            .prefetch_related('feature', 'feature__route') \
            .by_country_code(self.request.country_code) \
            .by_sources([PlatformMixin.ALL, PlatformMixin.MOBILE])
