from rest_framework import permissions, viewsets
from foods.api.serializers import (
    FoodSerializer,
    FoodCategorySerializer,
)
from foods.models import (
    FoodCategory,
    Food,
)


class FoodCategoryViewSet(viewsets.ModelViewSet):
    queryset = FoodCategory.objects.all().order_by("-created")
    serializer_class = FoodCategorySerializer
    permission_classes = [permissions.IsAuthenticated]


class FoodViewSet(viewsets.ModelViewSet):
    queryset = Food.objects.all().order_by("-created")
    serializer_class = FoodSerializer
    permission_classes = [permissions.IsAuthenticated]
