1 from django.http import HttpResponse
2 from rest_framework.generics import ListAPIView, RetrieveAPIView
3 from paypal.permissions import IsSubscribed
4 from . import serializers
5 from catalogue.models import Book, Collection
8 class CollectionList(ListAPIView):
9 queryset = Collection.objects.all()
10 serializer_class = serializers.CollectionListSerializer
13 class CollectionDetail(RetrieveAPIView):
14 queryset = Collection.objects.all()
16 serializer_class = serializers.CollectionSerializer
19 class BookDetail(RetrieveAPIView):
20 queryset = Book.objects.all()
22 serializer_class = serializers.BookDetailSerializer
25 class EpubView(RetrieveAPIView):
26 queryset = Book.objects.all()
28 permission_classes = [IsSubscribed]
30 def get(self, *args, **kwargs):
31 return HttpResponse(self.get_object().get_media('epub'))