Consolidate the docstring of the API methods into a class docstring.
Signed-off-by: Michael Price <loneviking72@gmail.com>
This commit is contained in:
committed by
Roberto Rosario
parent
ff9e291cd7
commit
1fc06a350b
@@ -44,7 +44,6 @@ class APIDeletedDocumentListView(generics.ListAPIView):
|
||||
"""
|
||||
Returns a list of all the trashed documents.
|
||||
"""
|
||||
|
||||
filter_backends = (MayanObjectPermissionsFilter,)
|
||||
mayan_object_permissions = {'GET': (permission_document_view,)}
|
||||
permission_classes = (MayanPermission,)
|
||||
@@ -55,8 +54,9 @@ class APIDeletedDocumentListView(generics.ListAPIView):
|
||||
class APIDeletedDocumentView(generics.RetrieveDestroyAPIView):
|
||||
"""
|
||||
Returns the selected trashed document details.
|
||||
delete: Delete the trashed document.
|
||||
get: Retreive the details of the trashed document.
|
||||
"""
|
||||
|
||||
mayan_object_permissions = {
|
||||
'DELETE': (permission_document_delete,),
|
||||
'GET': (permission_document_view,)
|
||||
@@ -65,29 +65,11 @@ class APIDeletedDocumentView(generics.RetrieveDestroyAPIView):
|
||||
queryset = Document.trash.all()
|
||||
serializer_class = DeletedDocumentSerializer
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
"""
|
||||
Delete the trashed document.
|
||||
"""
|
||||
|
||||
return super(APIDeletedDocumentView, self).delete(*args, **kwargs)
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Retreive the details of the trashed document.
|
||||
"""
|
||||
|
||||
return super(APIDeletedDocumentView, self).get(*args, **kwargs)
|
||||
|
||||
|
||||
class APIDeletedDocumentRestoreView(generics.GenericAPIView):
|
||||
"""
|
||||
Restore a trashed document.
|
||||
---
|
||||
POST:
|
||||
omit_serializer: true
|
||||
post: Restore a trashed document.
|
||||
"""
|
||||
|
||||
mayan_object_permissions = {
|
||||
'POST': (permission_document_restore,)
|
||||
}
|
||||
@@ -107,16 +89,8 @@ class APIDeletedDocumentRestoreView(generics.GenericAPIView):
|
||||
|
||||
class APIDocumentDownloadView(DownloadMixin, generics.RetrieveAPIView):
|
||||
"""
|
||||
Download the latest version of a document.
|
||||
---
|
||||
GET:
|
||||
omit_serializer: true
|
||||
parameters:
|
||||
- name: pk
|
||||
paramType: path
|
||||
type: number
|
||||
get: Download the latest version of a document.
|
||||
"""
|
||||
|
||||
mayan_object_permissions = {
|
||||
'GET': (permission_document_download,)
|
||||
}
|
||||
@@ -144,17 +118,15 @@ class APIDocumentDownloadView(DownloadMixin, generics.RetrieveAPIView):
|
||||
|
||||
|
||||
class APIDocumentListView(generics.ListCreateAPIView):
|
||||
"""
|
||||
get: Returns a list of all the documents.
|
||||
post: Create a new document.
|
||||
"""
|
||||
filter_backends = (MayanObjectPermissionsFilter,)
|
||||
mayan_object_permissions = {'GET': (permission_document_view,)}
|
||||
permission_classes = (MayanPermission,)
|
||||
queryset = Document.objects.all()
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Returns a list of all the documents.
|
||||
"""
|
||||
return super(APIDocumentListView, self).get(*args, **kwargs)
|
||||
|
||||
def get_serializer(self, *args, **kwargs):
|
||||
if not self.request:
|
||||
return None
|
||||
@@ -174,53 +146,10 @@ class APIDocumentListView(generics.ListCreateAPIView):
|
||||
)
|
||||
serializer.save(_user=self.request.user)
|
||||
|
||||
def post(self, *args, **kwargs):
|
||||
"""
|
||||
Create a new document.
|
||||
Endpoint returns a 202 status code to indicate that a document is not
|
||||
immediately created at request. From the request data, the creation of
|
||||
a document is instead queued as a background task. An ID that
|
||||
represents the eventual document is returned.
|
||||
---
|
||||
omit_serializer: false
|
||||
parameters:
|
||||
- name: description
|
||||
paramType: form
|
||||
type: file string
|
||||
- name: document_type
|
||||
paramType: form
|
||||
required: true
|
||||
type: file string
|
||||
- name: file
|
||||
paramType: form
|
||||
required: true
|
||||
type: file object
|
||||
- name: label
|
||||
paramType: form
|
||||
type: file string
|
||||
- name: language
|
||||
paramType: form
|
||||
type: file string
|
||||
responseMessages:
|
||||
- code: 202
|
||||
message: Accepted
|
||||
"""
|
||||
return super(APIDocumentListView, self).post(*args, **kwargs)
|
||||
|
||||
|
||||
class APIDocumentVersionDownloadView(DownloadMixin, generics.RetrieveAPIView):
|
||||
"""
|
||||
Download a document version.
|
||||
---
|
||||
GET:
|
||||
omit_serializer: true
|
||||
parameters:
|
||||
- name: pk
|
||||
paramType: path
|
||||
type: number
|
||||
- name: preserve_extension
|
||||
paramType: query
|
||||
type: boolean
|
||||
get: Download a document version.
|
||||
"""
|
||||
lookup_url_kwarg = 'version_pk'
|
||||
|
||||
@@ -271,8 +200,11 @@ class APIDocumentVersionDownloadView(DownloadMixin, generics.RetrieveAPIView):
|
||||
class APIDocumentView(generics.RetrieveUpdateDestroyAPIView):
|
||||
"""
|
||||
Returns the selected document details.
|
||||
delete: Move the selected document to the thrash.
|
||||
get: Return the details of the selected document.
|
||||
patch: Edit the properties of the selected document.
|
||||
put: Edit the properties of the selected document.
|
||||
"""
|
||||
|
||||
mayan_object_permissions = {
|
||||
'GET': (permission_document_view,),
|
||||
'PUT': (permission_document_properties_edit,),
|
||||
@@ -282,20 +214,6 @@ class APIDocumentView(generics.RetrieveUpdateDestroyAPIView):
|
||||
permission_classes = (MayanPermission,)
|
||||
queryset = Document.objects.all()
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
"""
|
||||
Move the selected document to the thrash.
|
||||
"""
|
||||
|
||||
return super(APIDocumentView, self).delete(*args, **kwargs)
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Return the details of the selected document.
|
||||
"""
|
||||
|
||||
return super(APIDocumentView, self).get(*args, **kwargs)
|
||||
|
||||
def get_serializer(self, *args, **kwargs):
|
||||
if not self.request:
|
||||
return None
|
||||
@@ -315,42 +233,11 @@ class APIDocumentView(generics.RetrieveUpdateDestroyAPIView):
|
||||
else:
|
||||
return WritableDocumentSerializer
|
||||
|
||||
def patch(self, *args, **kwargs):
|
||||
"""
|
||||
Edit the properties of the selected document.
|
||||
"""
|
||||
|
||||
return super(APIDocumentView, self).patch(*args, **kwargs)
|
||||
|
||||
def put(self, *args, **kwargs):
|
||||
"""
|
||||
Edit the properties of the selected document.
|
||||
"""
|
||||
|
||||
return super(APIDocumentView, self).put(*args, **kwargs)
|
||||
|
||||
|
||||
class APIDocumentPageImageView(generics.RetrieveAPIView):
|
||||
"""
|
||||
Returns an image representation of the selected document.
|
||||
---
|
||||
GET:
|
||||
omit_serializer: true
|
||||
parameters:
|
||||
- name: width
|
||||
description: Width of the desired image representation.
|
||||
paramType: query
|
||||
type: number
|
||||
- name: height
|
||||
description: Height of the desired image representation.
|
||||
paramType: query
|
||||
type: number
|
||||
- name: zoom
|
||||
description: Zoom level of the image to be generated, numeric value only.
|
||||
paramType: query
|
||||
type: number
|
||||
get: Returns an image representation of the selected document.
|
||||
"""
|
||||
|
||||
lookup_url_kwarg = 'page_pk'
|
||||
|
||||
def get_document(self):
|
||||
@@ -407,19 +294,13 @@ class APIDocumentPageImageView(generics.RetrieveAPIView):
|
||||
|
||||
class APIDocumentPageView(generics.RetrieveUpdateAPIView):
|
||||
"""
|
||||
Returns the selected document page details.
|
||||
get: Returns the selected document page details.
|
||||
patch: Edit the selected document page.
|
||||
put: Edit the selected document page.
|
||||
"""
|
||||
|
||||
lookup_url_kwarg = 'page_pk'
|
||||
serializer_class = DocumentPageSerializer
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Returns the selected document page details.
|
||||
"""
|
||||
|
||||
return super(APIDocumentPageView, self).get(*args, **kwargs)
|
||||
|
||||
def get_document(self):
|
||||
if self.request.method == 'GET':
|
||||
permission_required = permission_document_view
|
||||
@@ -441,22 +322,12 @@ class APIDocumentPageView(generics.RetrieveUpdateAPIView):
|
||||
def get_queryset(self):
|
||||
return self.get_document_version().pages.all()
|
||||
|
||||
def patch(self, *args, **kwargs):
|
||||
"""
|
||||
Edit the selected document page.
|
||||
"""
|
||||
|
||||
return super(APIDocumentPageView, self).patch(*args, **kwargs)
|
||||
|
||||
def put(self, *args, **kwargs):
|
||||
"""
|
||||
Edit the selected document page.
|
||||
"""
|
||||
|
||||
return super(APIDocumentPageView, self).put(*args, **kwargs)
|
||||
|
||||
|
||||
class APIDocumentTypeListView(generics.ListCreateAPIView):
|
||||
"""
|
||||
get: Returns a list of all the document types.
|
||||
post: Create a new document type.
|
||||
"""
|
||||
filter_backends = (MayanObjectPermissionsFilter,)
|
||||
mayan_object_permissions = {'GET': (permission_document_type_view,)}
|
||||
mayan_view_permissions = {'POST': (permission_document_type_create,)}
|
||||
@@ -464,13 +335,6 @@ class APIDocumentTypeListView(generics.ListCreateAPIView):
|
||||
queryset = DocumentType.objects.all()
|
||||
serializer_class = DocumentTypeSerializer
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Returns a list of all the document types.
|
||||
"""
|
||||
|
||||
return super(APIDocumentTypeListView, self).get(*args, **kwargs)
|
||||
|
||||
def get_serializer(self, *args, **kwargs):
|
||||
if not self.request:
|
||||
return None
|
||||
@@ -483,19 +347,14 @@ class APIDocumentTypeListView(generics.ListCreateAPIView):
|
||||
else:
|
||||
return WritableDocumentTypeSerializer
|
||||
|
||||
def post(self, *args, **kwargs):
|
||||
"""
|
||||
Create a new document type.
|
||||
"""
|
||||
|
||||
return super(APIDocumentTypeListView, self).post(*args, **kwargs)
|
||||
|
||||
|
||||
class APIDocumentTypeView(generics.RetrieveUpdateDestroyAPIView):
|
||||
"""
|
||||
Returns the selected document type details.
|
||||
delete: Delete the selected document type.
|
||||
get: Return the details of the selected document type.
|
||||
patch: Edit the properties of the selected document type.
|
||||
put: Edit the properties of the selected document type.
|
||||
"""
|
||||
|
||||
mayan_object_permissions = {
|
||||
'GET': (permission_document_type_view,),
|
||||
'PUT': (permission_document_type_edit,),
|
||||
@@ -505,20 +364,6 @@ class APIDocumentTypeView(generics.RetrieveUpdateDestroyAPIView):
|
||||
permission_classes = (MayanPermission,)
|
||||
queryset = DocumentType.objects.all()
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
"""
|
||||
Delete the selected document type.
|
||||
"""
|
||||
|
||||
return super(APIDocumentTypeView, self).delete(*args, **kwargs)
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Return the details of the selected document type.
|
||||
"""
|
||||
|
||||
return super(APIDocumentTypeView, self).get(*args, **kwargs)
|
||||
|
||||
def get_serializer(self, *args, **kwargs):
|
||||
if not self.request:
|
||||
return None
|
||||
@@ -531,20 +376,6 @@ class APIDocumentTypeView(generics.RetrieveUpdateDestroyAPIView):
|
||||
else:
|
||||
return WritableDocumentTypeSerializer
|
||||
|
||||
def patch(self, *args, **kwargs):
|
||||
"""
|
||||
Edit the properties of the selected document type.
|
||||
"""
|
||||
|
||||
return super(APIDocumentTypeView, self).patch(*args, **kwargs)
|
||||
|
||||
def put(self, *args, **kwargs):
|
||||
"""
|
||||
Edit the properties of the selected document type.
|
||||
"""
|
||||
|
||||
return super(APIDocumentTypeView, self).put(*args, **kwargs)
|
||||
|
||||
|
||||
class APIDocumentTypeDocumentListView(generics.ListAPIView):
|
||||
"""
|
||||
@@ -566,18 +397,14 @@ class APIDocumentTypeDocumentListView(generics.ListAPIView):
|
||||
|
||||
|
||||
class APIRecentDocumentListView(generics.ListAPIView):
|
||||
"""
|
||||
get: Return a list of the recent documents for the current user.
|
||||
"""
|
||||
serializer_class = RecentDocumentSerializer
|
||||
|
||||
def get_queryset(self):
|
||||
return RecentDocument.objects.filter(user=self.request.user)
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Return a list of the recent documents for the current user.
|
||||
"""
|
||||
|
||||
return super(APIRecentDocumentListView, self).get(*args, **kwargs)
|
||||
|
||||
|
||||
class APIDocumentVersionPageListView(generics.ListAPIView):
|
||||
serializer_class = DocumentPageSerializer
|
||||
@@ -601,9 +428,9 @@ class APIDocumentVersionPageListView(generics.ListAPIView):
|
||||
|
||||
class APIDocumentVersionsListView(generics.ListCreateAPIView):
|
||||
"""
|
||||
Return a list of the selected document's versions.
|
||||
get: Return a list of the selected document's versions.
|
||||
post: Create a new document version.
|
||||
"""
|
||||
|
||||
filter_backends = (MayanObjectPermissionsFilter,)
|
||||
mayan_object_permissions = {
|
||||
'GET': (permission_document_version_view,),
|
||||
@@ -642,30 +469,16 @@ class APIDocumentVersionsListView(generics.ListCreateAPIView):
|
||||
)
|
||||
serializer.save(document=document, _user=self.request.user)
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
"""
|
||||
Create a new document version.
|
||||
"""
|
||||
|
||||
return super(
|
||||
APIDocumentVersionsListView, self
|
||||
).post(request, *args, **kwargs)
|
||||
|
||||
|
||||
class APIDocumentVersionView(generics.RetrieveUpdateDestroyAPIView):
|
||||
"""
|
||||
Returns the selected document version details.
|
||||
delete: Delete the selected document version.
|
||||
get: Returns the selected document version details.
|
||||
patch: Edit the selected document version.
|
||||
put: Edit the selected document version.
|
||||
"""
|
||||
|
||||
lookup_url_kwarg = 'version_pk'
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
"""
|
||||
Delete the selected document version.
|
||||
"""
|
||||
|
||||
return super(APIDocumentVersionView, self).delete(*args, **kwargs)
|
||||
|
||||
def get_document(self):
|
||||
if self.request.method == 'GET':
|
||||
permission_required = permission_document_view
|
||||
@@ -695,17 +508,3 @@ class APIDocumentVersionView(generics.RetrieveUpdateDestroyAPIView):
|
||||
return DocumentVersionSerializer
|
||||
else:
|
||||
return WritableDocumentVersionSerializer
|
||||
|
||||
def patch(self, *args, **kwargs):
|
||||
"""
|
||||
Edit the selected document version.
|
||||
"""
|
||||
|
||||
return super(APIDocumentVersionView, self).patch(*args, **kwargs)
|
||||
|
||||
def put(self, *args, **kwargs):
|
||||
"""
|
||||
Edit the selected document version.
|
||||
"""
|
||||
|
||||
return super(APIDocumentVersionView, self).put(*args, **kwargs)
|
||||
|
||||
Reference in New Issue
Block a user