from rest_framework import permissions, viewsets

from books.api import serializers
from books import models


class AuthorViewSet(viewsets.ModelViewSet):
    queryset = models.Author.objects.all().order_by("-created")
    serializer_class = serializers.AuthorSerializer
    permission_classes = [permissions.IsAuthenticated]


class BookViewSet(viewsets.ModelViewSet):
    queryset = models.Book.objects.all().order_by("-created")
    serializer_class = serializers.BookSerializer
    permission_classes = [permissions.IsAuthenticated]


class PaperViewSet(viewsets.ModelViewSet):
    queryset = models.Paper.objects.all().order_by("-created")
    serializer_class = serializers.PaperSerializer
    permission_classes = [permissions.IsAuthenticated]
