diff --git a/api/serializers.py b/api/serializers.py index 3307ac98..536414b8 100644 --- a/api/serializers.py +++ b/api/serializers.py @@ -719,12 +719,28 @@ class EMailAddressSerializer(NamespacedHMSerializer): # PRINTER -class PrintJobSerializer(NamespacedHMSerializer): - """Serialize the jobs for printer +class PrintableJobSerializer(NamespacedHMSerializer): + """Serialize the jobs to be printed """ + file = serializers.FileField(use_url=False) class Meta: model = printer.JobWithOptions exclude = ('price', 'pages') + extra_kwargs = { + 'api_url': {'view_name': 'printablejobs-detail'} + } + +class HistoryJobSerializer(NamespacedHMSerializer): + """Serialize past, cancelled jobs + """ + file = serializers.FileField(use_url=False) + class Meta: + model = printer.JobWithOptions + exclude = ('price', 'pages') + extra_kwargs = { + 'api_url': {'view_name': 'historyjobs-detail'} + } + # SERVICE REGEN diff --git a/api/urls.py b/api/urls.py index 497e7d68..af84a7d7 100644 --- a/api/urls.py +++ b/api/urls.py @@ -120,8 +120,8 @@ router.register_view(r'dns/reverse-zones', views.DNSReverseZonesView), router.register_view(r'mailing/standard', views.StandardMailingView), router.register_view(r'mailing/club', views.ClubMailingView), # PRINTER -router.register_viewset(r'printer/printable-jobs', views.PrintableJobsView) -router.register_viewset(r'printer/history-jobs', views.HistoryJobsView) +router.register_viewset(r'printer/printable-jobs', views.PrintableJobsViewSet, 'printablejobs') +router.register_viewset(r'printer/history-jobs', views.HistoryJobsViewSet, 'historyjobs') # TOKEN AUTHENTICATION router.register_view(r'token-auth', views.ObtainExpiringAuthToken) diff --git a/api/views.py b/api/views.py index 7a68b896..7b7c3a45 100644 --- a/api/views.py +++ b/api/views.py @@ -673,17 +673,17 @@ class ClubMailingView(generics.ListAPIView): serializer_class = serializers.MailingSerializer # PRINTER -class PrintableJobsView(viewsets.ModelViewSet): - """Api Root Jobs +class PrintableJobsViewSet(viewsets.ModelViewSet): + """Exposes list of printable jobs """ queryset = printer.JobWithOptions.objects.filter(status='Printable') - serializer_class = serializers.PrintJobSerializer + serializer_class = serializers.PrintableJobSerializer -class HistoryJobsView(viewsets.ModelViewSet): - """Api Root Jobs +class HistoryJobsViewSet(viewsets.ModelViewSet): + """Exposes past jobs """ queryset = printer.JobWithOptions.objects.exclude(status='Printable').exclude(status='Pending') - serializer_class = serializers.PrintJobSerializer + serializer_class = serializers.HistoryJobSerializer # TOKEN AUTHENTICATION