from rest_framework import permissions, viewsets

from podcasts.api import serializers
from podcasts import models


class ProducerViewSet(viewsets.ModelViewSet):
    queryset = models.Producer.objects.all().order_by("-created")
    serializer_class = serializers.ProducerSerializer
    permission_classes = [permissions.IsAuthenticated]


class PodcastViewSet(viewsets.ModelViewSet):
    queryset = models.Podcast.objects.all().order_by("-created")
    serializer_class = serializers.PodcastSerializer
    permission_classes = [permissions.IsAuthenticated]


class PodcastEpisodeViewSet(viewsets.ModelViewSet):
    queryset = models.PodcastEpisode.objects.all().order_by("-created")
    serializer_class = serializers.PodcastEpisodeSerializer
    permission_classes = [permissions.IsAuthenticated]
