from django.conf import settings
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework import permissions, viewsets

from ..models import Cassa
from ..serializers import CassaSerializer

permission = (
    permissions.AllowAny if settings.DEBUG else permissions.IsAuthenticatedOrReadOnly
)


class CassaViewSet(viewsets.ModelViewSet):
    permission_classes = [permission]
    queryset = Cassa.objects.all()
    serializer_class = CassaSerializer
    filter_backends = [DjangoFilterBackend]
    filterset_fields = ["negozio", "negozio__azienda"]

from django.conf import settings
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework import permissions, viewsets

from ..models import Cassa
from ..serializers import CassaSerializer

permission = (
    permissions.AllowAny if settings.DEBUG else permissions.IsAuthenticatedOrReadOnly
)


class CassaViewSet(viewsets.ModelViewSet):
    permission_classes = [permission]
    queryset = Cassa.objects.all()
    serializer_class = CassaSerializer
    filter_backends = [DjangoFilterBackend]
    filterset_fields = ["negozio", "negozio__azienda"]
