8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-16 08:23:12 +00:00

[Api/printer] API endpoints for printer

This commit is contained in:
Maxime Bombar 2018-10-12 12:53:43 +02:00 committed by root
parent d3d64c62fb
commit 909c378c3f
3 changed files with 26 additions and 10 deletions

View file

@ -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

View file

@ -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)

View file

@ -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