8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-24 20:33:11 +00:00

[Printer/Api] Serialize abstract printoperation model

This commit is contained in:
Maxime Bombar 2018-10-26 01:26:47 +02:00 committed by root
parent 4b530750f4
commit 6c903b371c
3 changed files with 18 additions and 1 deletions

View file

@ -719,6 +719,15 @@ class EMailAddressSerializer(NamespacedHMSerializer):
# PRINTER
class PrintOperationSerializer(NamespacedHMSerializer):
"""Serialiaze abstract print operation
"""
class Meta:
model = printer.PrintOperation
extra_kwargs = {
'api_url' : {'view_name': 'printoperation-detail'}
}
class PrintableJobSerializer(NamespacedHMSerializer):
"""Serialize the jobs to be printed
"""

View file

@ -122,6 +122,7 @@ router.register_view(r'mailing/club', views.ClubMailingView),
# PRINTER
router.register_viewset(r'printer/printable-jobs', views.PrintableJobsViewSet, 'printablejobs')
router.register_viewset(r'printer/history-jobs', views.HistoryJobsViewSet, 'historyjobs')
router.register_viewset(r'printer/printoperation', views.PrintOperationViewSet, 'printoperation')
# TOKEN AUTHENTICATION
router.register_view(r'token-auth', views.ObtainExpiringAuthToken)

View file

@ -673,6 +673,13 @@ class ClubMailingView(generics.ListAPIView):
serializer_class = serializers.MailingSerializer
# PRINTER
class PrintOperationViewSet(viewsets.ModelViewSet):
"""Exposes list of printoperations
"""
queryset = printer.PrintOperation.objects.all()
serializer_class = serializers.PrintOperationSerializer
class PrintableJobsViewSet(viewsets.ModelViewSet):
"""Exposes list of printable jobs
"""
@ -685,7 +692,7 @@ class HistoryJobsViewSet(viewsets.ModelViewSet):
queryset = printer.JobWithOptions.objects.exclude(status='Printable').exclude(status='Pending')
serializer_class = serializers.HistoryJobSerializer
# TOKEN AUTHENTICATION