diff --git a/mayan/apps/documents/api.py b/mayan/apps/documents/api.py index 6029b6cb5a..acff390240 100644 --- a/mayan/apps/documents/api.py +++ b/mayan/apps/documents/api.py @@ -18,16 +18,16 @@ from permissions.models import Permission from .conf.settings import DISPLAY_SIZE, ZOOM_MAX_LEVEL, ZOOM_MIN_LEVEL from .models import Document from .permissions import PERMISSION_DOCUMENT_VIEW -from .resources import DocumentResourceSimple +from .resources import ResourceDocument logger = logging.getLogger(__name__) # API Views -class APIReadOnlyInstanceModelView(RetrieveAPIView): +class APIDocumentView(RetrieveAPIView): allowed_methods = ['GET'] - serializer_class = DocumentResourceSimple + serializer_class = ResourceDocument queryset = Document.objects.all() diff --git a/mayan/apps/documents/registry.py b/mayan/apps/documents/registry.py index bd75910c4a..e6ab271969 100644 --- a/mayan/apps/documents/registry.py +++ b/mayan/apps/documents/registry.py @@ -3,7 +3,7 @@ from __future__ import absolute_import from django.conf.urls import url from .cleanup import cleanup -from .api import APIReadOnlyInstanceModelView, APIDocumentImageView +from .api import APIDocumentView, APIDocumentImageView bootstrap_models = [ { @@ -17,6 +17,6 @@ bootstrap_models = [ cleanup_functions = [cleanup] version_0_api_services = [ - {'urlpattern': url(r'^document/(?P[0-9]+)/$', APIReadOnlyInstanceModelView.as_view(), name='document-detail'), 'description': 'Show document data', 'url': 'document/'}, + {'urlpattern': url(r'^document/(?P[0-9]+)/$', APIDocumentView.as_view(), name='document-detail'), 'description': 'Show document data', 'url': 'document/'}, {'urlpattern': url(r'^document/(?P[0-9]+)/image/$', APIDocumentImageView.as_view(), name='document-image'), 'description': 'Return a base64 image of the document', 'url': 'document//image/?page=&zoom=&rotate='}, ] diff --git a/mayan/apps/documents/resources.py b/mayan/apps/documents/resources.py index d03276f938..454fde8211 100644 --- a/mayan/apps/documents/resources.py +++ b/mayan/apps/documents/resources.py @@ -7,39 +7,7 @@ from rest_framework import serializers from .models import Document -class DocumentResourceSimple(serializers.HyperlinkedModelSerializer): - def versions(self, instance): - return [ - { - 'version': version.get_formated_version(), - 'major': version.major, - 'minor': version.minor, - 'micro': version.micro, - 'release_level': version.release_level, - 'serial': version.serial, - 'timestamp': version.timestamp, - 'comment': version.comment, - 'mimetype': version.mimetype, - 'encoding': version.encoding, - 'filename': version.filename, - 'checksum': version.checksum, - 'download': reverse('document_version_download', args=[version.pk]), - 'stored_filename': version.file.name, - # TODO: Add transformations - 'pages': [ - { - 'content': page.content, - 'page_label': page.page_label, - 'page_number': page.page_number, - } - for page in version.pages.all() - ] - - } - for version in instance.versions.all() - ] - +class ResourceDocument(serializers.HyperlinkedModelSerializer): class Meta: model = Document - #fields = ('url', 'pk', 'document_type', 'uuid', 'date_added', 'description', 'expensive_methods', 'versions') - fields = ('url', 'document_type', 'uuid', 'date_added', 'description')#, 'versions') + fields = ('url', 'document_type', 'uuid', 'date_added', 'description')