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
@@ -18,13 +18,10 @@ from .serializers import (
|
||||
|
||||
|
||||
class APIObjectACLListView(generics.ListCreateAPIView):
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Returns a list of all the object's access control lists
|
||||
"""
|
||||
|
||||
return super(APIObjectACLListView, self).get(*args, **kwargs)
|
||||
|
||||
"""
|
||||
get: Returns a list of all the object's access control lists
|
||||
post: Create a new access control list for the selected object.
|
||||
"""
|
||||
def get_content_object(self):
|
||||
content_type = get_object_or_404(
|
||||
ContentType, app_label=self.kwargs['app_label'],
|
||||
@@ -80,31 +77,14 @@ class APIObjectACLListView(generics.ListCreateAPIView):
|
||||
else:
|
||||
return WritableAccessControlListSerializer
|
||||
|
||||
def post(self, *args, **kwargs):
|
||||
"""
|
||||
Create a new access control list for the selected object.
|
||||
"""
|
||||
|
||||
return super(APIObjectACLListView, self).post(*args, **kwargs)
|
||||
|
||||
|
||||
class APIObjectACLView(generics.RetrieveDestroyAPIView):
|
||||
"""
|
||||
delete: Delete the selected access control list.
|
||||
get: Returns the details of the selected access control list.
|
||||
"""
|
||||
serializer_class = AccessControlListSerializer
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
"""
|
||||
Delete the selected access control list.
|
||||
"""
|
||||
|
||||
return super(APIObjectACLView, self).delete(*args, **kwargs)
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Returns the details of the selected access control list.
|
||||
"""
|
||||
|
||||
return super(APIObjectACLView, self).get(*args, **kwargs)
|
||||
|
||||
def get_content_object(self):
|
||||
if self.request.method == 'GET':
|
||||
permission_required = permission_acl_view
|
||||
@@ -136,15 +116,10 @@ class APIObjectACLView(generics.RetrieveDestroyAPIView):
|
||||
|
||||
|
||||
class APIObjectACLPermissionListView(generics.ListCreateAPIView):
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Returns the access control list permission list.
|
||||
"""
|
||||
|
||||
return super(
|
||||
APIObjectACLPermissionListView, self
|
||||
).get(*args, **kwargs)
|
||||
|
||||
"""
|
||||
get: Returns the access control list permission list.
|
||||
post: Add a new permission to the selected access control list.
|
||||
"""
|
||||
def get_acl(self):
|
||||
return get_object_or_404(
|
||||
self.get_content_object().acls, pk=self.kwargs['pk']
|
||||
@@ -197,38 +172,15 @@ class APIObjectACLPermissionListView(generics.ListCreateAPIView):
|
||||
|
||||
return context
|
||||
|
||||
def post(self, *args, **kwargs):
|
||||
"""
|
||||
Add a new permission to the selected access control list.
|
||||
"""
|
||||
|
||||
return super(
|
||||
APIObjectACLPermissionListView, self
|
||||
).post(*args, **kwargs)
|
||||
|
||||
|
||||
class APIObjectACLPermissionView(generics.RetrieveDestroyAPIView):
|
||||
"""
|
||||
delete: Remove the permission from the selected access control list.
|
||||
get: Returns the details of the selected access control list permission.
|
||||
"""
|
||||
lookup_url_kwarg = 'permission_pk'
|
||||
serializer_class = AccessControlListPermissionSerializer
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
"""
|
||||
Remove the permission from the selected access control list.
|
||||
"""
|
||||
|
||||
return super(
|
||||
APIObjectACLPermissionView, self
|
||||
).delete(*args, **kwargs)
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Returns the details of the selected access control list permission.
|
||||
"""
|
||||
|
||||
return super(
|
||||
APIObjectACLPermissionView, self
|
||||
).get(*args, **kwargs)
|
||||
|
||||
def get_acl(self):
|
||||
return get_object_or_404(
|
||||
self.get_content_object().acls, pk=self.kwargs['pk']
|
||||
|
||||
@@ -45,6 +45,10 @@ class APIDocumentCabinetListView(generics.ListAPIView):
|
||||
|
||||
|
||||
class APICabinetListView(generics.ListCreateAPIView):
|
||||
"""
|
||||
get: Returns a list of all the cabinets.
|
||||
post: Create a new cabinet
|
||||
"""
|
||||
filter_backends = (MayanObjectPermissionsFilter,)
|
||||
mayan_object_permissions = {'GET': (permission_cabinet_view,)}
|
||||
mayan_view_permissions = {'POST': (permission_cabinet_create,)}
|
||||
@@ -63,20 +67,14 @@ class APICabinetListView(generics.ListCreateAPIView):
|
||||
elif self.request.method == 'POST':
|
||||
return WritableCabinetSerializer
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Returns a list of all the cabinets.
|
||||
"""
|
||||
return super(APICabinetListView, self).get(*args, **kwargs)
|
||||
|
||||
def post(self, *args, **kwargs):
|
||||
"""
|
||||
Create a new cabinet.
|
||||
"""
|
||||
return super(APICabinetListView, self).post(*args, **kwargs)
|
||||
|
||||
|
||||
class APICabinetView(generics.RetrieveUpdateDestroyAPIView):
|
||||
"""
|
||||
delete: Delete the selected cabinet.
|
||||
get: Returns the details of the selected cabinet.
|
||||
patch: Edit the selected cabinet.
|
||||
put: Edit the selected cabinet.
|
||||
"""
|
||||
filter_backends = (MayanObjectPermissionsFilter,)
|
||||
mayan_object_permissions = {
|
||||
'GET': (permission_cabinet_view,),
|
||||
@@ -87,18 +85,6 @@ class APICabinetView(generics.RetrieveUpdateDestroyAPIView):
|
||||
permission_classes = (MayanPermission,)
|
||||
queryset = Cabinet.objects.all()
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
"""
|
||||
Delete the selected cabinet.
|
||||
"""
|
||||
return super(APICabinetView, self).delete(*args, **kwargs)
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Returns the details of the selected cabinet.
|
||||
"""
|
||||
return super(APICabinetView, self).get(*args, **kwargs)
|
||||
|
||||
def get_serializer(self, *args, **kwargs):
|
||||
if not self.request:
|
||||
return None
|
||||
@@ -111,24 +97,12 @@ class APICabinetView(generics.RetrieveUpdateDestroyAPIView):
|
||||
else:
|
||||
return WritableCabinetSerializer
|
||||
|
||||
def patch(self, *args, **kwargs):
|
||||
"""
|
||||
Edit the selected cabinet.
|
||||
"""
|
||||
return super(APICabinetView, self).patch(*args, **kwargs)
|
||||
|
||||
def put(self, *args, **kwargs):
|
||||
"""
|
||||
Edit the selected cabinet.
|
||||
"""
|
||||
return super(APICabinetView, self).put(*args, **kwargs)
|
||||
|
||||
|
||||
class APICabinetDocumentListView(generics.ListCreateAPIView):
|
||||
"""
|
||||
Returns a list of all the documents contained in a particular cabinet.
|
||||
get: Returns a list of all the documents contained in a particular cabinet.
|
||||
post: Add a document to the selected cabinet.
|
||||
"""
|
||||
|
||||
filter_backends = (MayanObjectPermissionsFilter,)
|
||||
mayan_object_permissions = {
|
||||
'GET': (permission_cabinet_view,),
|
||||
@@ -175,16 +149,12 @@ class APICabinetDocumentListView(generics.ListCreateAPIView):
|
||||
def perform_create(self, serializer):
|
||||
serializer.save(cabinet=self.get_cabinet())
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
"""
|
||||
Add a document to the selected cabinet.
|
||||
"""
|
||||
return super(APICabinetDocumentListView, self).post(
|
||||
request, *args, **kwargs
|
||||
)
|
||||
|
||||
|
||||
class APICabinetDocumentView(generics.RetrieveDestroyAPIView):
|
||||
"""
|
||||
delete: Remove a document from the selected cabinet.
|
||||
get: Returns the details of the selected cabinet document.
|
||||
"""
|
||||
filter_backends = (MayanObjectPermissionsFilter,)
|
||||
lookup_url_kwarg = 'document_pk'
|
||||
mayan_object_permissions = {
|
||||
@@ -193,22 +163,6 @@ class APICabinetDocumentView(generics.RetrieveDestroyAPIView):
|
||||
}
|
||||
serializer_class = CabinetDocumentSerializer
|
||||
|
||||
def delete(self, request, *args, **kwargs):
|
||||
"""
|
||||
Remove a document from the selected cabinet.
|
||||
"""
|
||||
|
||||
return super(APICabinetDocumentView, self).delete(
|
||||
request, *args, **kwargs
|
||||
)
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Returns the details of the selected cabinet document.
|
||||
"""
|
||||
|
||||
return super(APICabinetDocumentView, self).get(*args, **kwargs)
|
||||
|
||||
def get_cabinet(self):
|
||||
return get_object_or_404(Cabinet, pk=self.kwargs['pk'])
|
||||
|
||||
|
||||
@@ -16,6 +16,10 @@ from .serializers import (
|
||||
|
||||
|
||||
class APICheckedoutDocumentListView(generics.ListCreateAPIView):
|
||||
"""
|
||||
get: Returns a list of all the documents that are currently checked out.
|
||||
post: Checkout a document.
|
||||
"""
|
||||
def get_serializer(self, *args, **kwargs):
|
||||
if not self.request:
|
||||
return None
|
||||
@@ -42,25 +46,12 @@ class APICheckedoutDocumentListView(generics.ListCreateAPIView):
|
||||
document__pk__in=filtered_documents.values_list('pk', flat=True)
|
||||
)
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
"""
|
||||
Returns a list of all the documents that are currently checked out.
|
||||
"""
|
||||
|
||||
return super(
|
||||
APICheckedoutDocumentListView, self
|
||||
).get(request, *args, **kwargs)
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
"""
|
||||
Checkout a document.
|
||||
"""
|
||||
return super(
|
||||
APICheckedoutDocumentListView, self
|
||||
).post(request, *args, **kwargs)
|
||||
|
||||
|
||||
class APICheckedoutDocumentView(generics.RetrieveDestroyAPIView):
|
||||
"""
|
||||
get: Retrieve the details of the selected checked out document entry.
|
||||
delete: Checkin a document.
|
||||
"""
|
||||
serializer_class = DocumentCheckoutSerializer
|
||||
|
||||
def get_queryset(self):
|
||||
@@ -82,20 +73,7 @@ class APICheckedoutDocumentView(generics.RetrieveDestroyAPIView):
|
||||
elif self.request.method == 'DELETE':
|
||||
return DocumentCheckout.objects.all()
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
"""
|
||||
Retrieve the details of the selected checked out document entry.
|
||||
"""
|
||||
|
||||
return super(
|
||||
APICheckedoutDocumentView, self
|
||||
).get(request, *args, **kwargs)
|
||||
|
||||
def delete(self, request, *args, **kwargs):
|
||||
"""
|
||||
Checkin a document.
|
||||
"""
|
||||
|
||||
document = self.get_object().document
|
||||
|
||||
if document.checkout_info().user == request.user:
|
||||
|
||||
@@ -11,6 +11,5 @@ class APIContentTypeList(generics.ListAPIView):
|
||||
"""
|
||||
Returns a list of all the available content types.
|
||||
"""
|
||||
|
||||
serializer_class = ContentTypeSerializer
|
||||
queryset = ContentType.objects.order_by('app_label', 'model')
|
||||
|
||||
@@ -13,6 +13,10 @@ from .serializers import KeySerializer
|
||||
|
||||
|
||||
class APIKeyListView(generics.ListCreateAPIView):
|
||||
"""
|
||||
get: Returns a list of all the keys.
|
||||
post: Upload a new key.
|
||||
"""
|
||||
filter_backends = (MayanObjectPermissionsFilter,)
|
||||
mayan_object_permissions = {'GET': (permission_key_view,)}
|
||||
mayan_view_permissions = {'POST': (permission_key_upload,)}
|
||||
@@ -20,20 +24,12 @@ class APIKeyListView(generics.ListCreateAPIView):
|
||||
queryset = Key.objects.all()
|
||||
serializer_class = KeySerializer
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Returns a list of all the keys.
|
||||
"""
|
||||
return super(APIKeyListView, self).get(*args, **kwargs)
|
||||
|
||||
def post(self, *args, **kwargs):
|
||||
"""
|
||||
Upload a new key.
|
||||
"""
|
||||
return super(APIKeyListView, self).post(*args, **kwargs)
|
||||
|
||||
|
||||
class APIKeyView(generics.RetrieveDestroyAPIView):
|
||||
"""
|
||||
delete: Delete the selected key.
|
||||
get: Return the details of the selected key.
|
||||
"""
|
||||
filter_backends = (MayanObjectPermissionsFilter,)
|
||||
mayan_object_permissions = {
|
||||
'DELETE': (permission_key_delete,),
|
||||
@@ -41,17 +37,3 @@ class APIKeyView(generics.RetrieveDestroyAPIView):
|
||||
}
|
||||
queryset = Key.objects.all()
|
||||
serializer_class = KeySerializer
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
"""
|
||||
Delete the selected key.
|
||||
"""
|
||||
|
||||
return super(APIKeyView, self).delete(*args, **kwargs)
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Return the details of the selected key.
|
||||
"""
|
||||
|
||||
return super(APIKeyView, self).get(*args, **kwargs)
|
||||
|
||||
@@ -17,12 +17,10 @@ from .serializers import CommentSerializer, WritableCommentSerializer
|
||||
|
||||
|
||||
class APICommentListView(generics.ListCreateAPIView):
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Returns a list of all the document comments.
|
||||
"""
|
||||
return super(APICommentListView, self).get(*args, **kwargs)
|
||||
|
||||
"""
|
||||
get: Returns a list of all the document comments.
|
||||
post: Create a new document comment.
|
||||
"""
|
||||
def get_document(self):
|
||||
if self.request.method == 'GET':
|
||||
permission_required = permission_comment_view
|
||||
@@ -71,31 +69,15 @@ class APICommentListView(generics.ListCreateAPIView):
|
||||
|
||||
return context
|
||||
|
||||
def post(self, *args, **kwargs):
|
||||
"""
|
||||
Create a new document comment.
|
||||
"""
|
||||
return super(APICommentListView, self).post(*args, **kwargs)
|
||||
|
||||
|
||||
class APICommentView(generics.RetrieveDestroyAPIView):
|
||||
"""
|
||||
delete: Delete the selected document comment.
|
||||
get: Returns the details of the selected document comment.
|
||||
"""
|
||||
lookup_url_kwarg = 'comment_pk'
|
||||
serializer_class = CommentSerializer
|
||||
|
||||
def delete(self, request, *args, **kwargs):
|
||||
"""
|
||||
Delete the selected document comment.
|
||||
"""
|
||||
|
||||
return super(APICommentView, self).delete(request, *args, **kwargs)
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Returns the details of the selected document comment.
|
||||
"""
|
||||
|
||||
return super(APICommentView, self).get(*args, **kwargs)
|
||||
|
||||
def get_document(self):
|
||||
if self.request.method == 'GET':
|
||||
permission_required = permission_comment_view
|
||||
|
||||
@@ -22,28 +22,24 @@ from .serializers import (
|
||||
|
||||
|
||||
class APIIndexListView(generics.ListCreateAPIView):
|
||||
"""
|
||||
get: Returns a list of all the defined indexes.
|
||||
post: Create a new index.
|
||||
"""
|
||||
filter_backends = (MayanObjectPermissionsFilter,)
|
||||
mayan_object_permissions = {'GET': (permission_document_indexing_view,)}
|
||||
mayan_view_permissions = {'POST': (permission_document_indexing_create,)}
|
||||
queryset = Index.objects.all()
|
||||
serializer_class = IndexSerializer
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Returns a list of all the defined indexes.
|
||||
"""
|
||||
|
||||
return super(APIIndexListView, self).get(*args, **kwargs)
|
||||
|
||||
def post(self, *args, **kwargs):
|
||||
"""
|
||||
Create a new index.
|
||||
"""
|
||||
|
||||
return super(APIIndexListView, self).post(*args, **kwargs)
|
||||
|
||||
|
||||
class APIIndexView(generics.RetrieveUpdateDestroyAPIView):
|
||||
"""
|
||||
delete: Delete the selected index.
|
||||
get: Returns the details of the selected index.
|
||||
patch: Partially edit an index.
|
||||
put: Edit an index.
|
||||
"""
|
||||
mayan_object_permissions = {
|
||||
'GET': (permission_document_indexing_view,),
|
||||
'PUT': (permission_document_indexing_edit,),
|
||||
@@ -54,34 +50,6 @@ class APIIndexView(generics.RetrieveUpdateDestroyAPIView):
|
||||
queryset = Index.objects.all()
|
||||
serializer_class = IndexSerializer
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
"""
|
||||
Delete the selected index.
|
||||
"""
|
||||
|
||||
return super(APIIndexView, self).delete(*args, **kwargs)
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Returns the details of the selected index.
|
||||
"""
|
||||
|
||||
return super(APIIndexView, self).get(*args, **kwargs)
|
||||
|
||||
def patch(self, *args, **kwargs):
|
||||
"""
|
||||
Partially edit an index.
|
||||
"""
|
||||
|
||||
return super(APIIndexView, self).patch(*args, **kwargs)
|
||||
|
||||
def put(self, *args, **kwargs):
|
||||
"""
|
||||
Edit an index.
|
||||
"""
|
||||
|
||||
return super(APIIndexView, self).put(*args, **kwargs)
|
||||
|
||||
|
||||
class APIIndexNodeInstanceDocumentListView(generics.ListAPIView):
|
||||
"""
|
||||
@@ -106,19 +74,21 @@ class APIIndexNodeInstanceDocumentListView(generics.ListAPIView):
|
||||
|
||||
|
||||
class APIIndexTemplateListView(generics.ListAPIView):
|
||||
"""
|
||||
get: Returns a list of all the template nodes for the selected index.
|
||||
"""
|
||||
filter_backends = (MayanObjectPermissionsFilter,)
|
||||
mayan_object_permissions = {'GET': (permission_document_indexing_view,)}
|
||||
serializer_class = IndexTemplateNodeSerializer
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Returns a list of all the template nodes for the selected index.
|
||||
"""
|
||||
|
||||
return super(APIIndexTemplateListView, self).get(*args, **kwargs)
|
||||
|
||||
|
||||
class APIIndexTemplateView(generics.RetrieveUpdateDestroyAPIView):
|
||||
"""
|
||||
delete: Delete the selected index template node.
|
||||
get: Returns the details of the selected index template node.
|
||||
patch: Partially edit an index template node.
|
||||
put: Edit an index template node.
|
||||
"""
|
||||
serializer_class = IndexTemplateNodeSerializer
|
||||
queryset = IndexTemplateNode.objects.all()
|
||||
|
||||
@@ -130,34 +100,6 @@ class APIIndexTemplateView(generics.RetrieveUpdateDestroyAPIView):
|
||||
'DELETE': (permission_document_indexing_edit,)
|
||||
}
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
"""
|
||||
Delete the selected index template node.
|
||||
"""
|
||||
|
||||
return super(APIIndexTemplateView, self).delete(*args, **kwargs)
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Returns the details of the selected index template node.
|
||||
"""
|
||||
|
||||
return super(APIIndexTemplateView, self).get(*args, **kwargs)
|
||||
|
||||
def patch(self, *args, **kwargs):
|
||||
"""
|
||||
Partially edit an index template node.
|
||||
"""
|
||||
|
||||
return super(APIIndexTemplateView, self).patch(*args, **kwargs)
|
||||
|
||||
def put(self, *args, **kwargs):
|
||||
"""
|
||||
Edit an index template node.
|
||||
"""
|
||||
|
||||
return super(APIIndexTemplateView, self).put(*args, **kwargs)
|
||||
|
||||
|
||||
class APIDocumentIndexListView(generics.ListAPIView):
|
||||
"""
|
||||
|
||||
@@ -25,20 +25,15 @@ from .serializers import (
|
||||
|
||||
|
||||
class APIDocumentTypeWorkflowListView(generics.ListAPIView):
|
||||
"""
|
||||
get: Returns a list of all the document type workflows.
|
||||
"""
|
||||
filter_backends = (MayanObjectPermissionsFilter,)
|
||||
mayan_object_permissions = {
|
||||
'GET': (permission_workflow_view,),
|
||||
}
|
||||
serializer_class = WorkflowSerializer
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Returns a list of all the document type workflows.
|
||||
"""
|
||||
return super(
|
||||
APIDocumentTypeWorkflowListView, self
|
||||
).get(*args, **kwargs)
|
||||
|
||||
def get_document_type(self):
|
||||
document_type = get_object_or_404(DocumentType, pk=self.kwargs['pk'])
|
||||
|
||||
@@ -54,18 +49,15 @@ class APIDocumentTypeWorkflowListView(generics.ListAPIView):
|
||||
|
||||
|
||||
class APIWorkflowDocumentTypeList(generics.ListCreateAPIView):
|
||||
"""
|
||||
get: Returns a list of all the document types attached to a workflow.
|
||||
post: Attach a document type to a specified workflow.
|
||||
"""
|
||||
filter_backends = (MayanObjectPermissionsFilter,)
|
||||
mayan_object_permissions = {
|
||||
'GET': (permission_document_type_view,),
|
||||
}
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Returns a list of all the document types attached to a workflow.
|
||||
"""
|
||||
|
||||
return super(APIWorkflowDocumentTypeList, self).get(*args, **kwargs)
|
||||
|
||||
def get_queryset(self):
|
||||
"""
|
||||
This view returns a list of document types that belong to a workflow.
|
||||
@@ -119,17 +111,12 @@ class APIWorkflowDocumentTypeList(generics.ListCreateAPIView):
|
||||
|
||||
return workflow
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
"""
|
||||
Attach a document type to a specified workflow.
|
||||
"""
|
||||
|
||||
return super(
|
||||
APIWorkflowDocumentTypeList, self
|
||||
).post(request, *args, **kwargs)
|
||||
|
||||
|
||||
class APIWorkflowDocumentTypeView(generics.RetrieveDestroyAPIView):
|
||||
"""
|
||||
delete: Remove a document type from the selected workflow.
|
||||
get: Returns the details of the selected workflow document type.
|
||||
"""
|
||||
filter_backends = (MayanObjectPermissionsFilter,)
|
||||
lookup_url_kwarg = 'document_type_pk'
|
||||
mayan_object_permissions = {
|
||||
@@ -137,22 +124,6 @@ class APIWorkflowDocumentTypeView(generics.RetrieveDestroyAPIView):
|
||||
}
|
||||
serializer_class = WorkflowDocumentTypeSerializer
|
||||
|
||||
def delete(self, request, *args, **kwargs):
|
||||
"""
|
||||
Remove a document type from the selected workflow.
|
||||
"""
|
||||
|
||||
return super(
|
||||
APIWorkflowDocumentTypeView, self
|
||||
).delete(request, *args, **kwargs)
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Returns the details of the selected workflow document type.
|
||||
"""
|
||||
|
||||
return super(APIWorkflowDocumentTypeView, self).get(*args, **kwargs)
|
||||
|
||||
def get_queryset(self):
|
||||
return self.get_workflow().document_types.all()
|
||||
|
||||
@@ -179,7 +150,6 @@ class APIWorkflowDocumentTypeView(generics.RetrieveDestroyAPIView):
|
||||
into a generic API class?
|
||||
RESEARCH: Reuse get_workflow method from APIWorkflowDocumentTypeList?
|
||||
"""
|
||||
|
||||
if self.request.method == 'GET':
|
||||
permission_required = permission_workflow_view
|
||||
else:
|
||||
@@ -199,23 +169,20 @@ class APIWorkflowDocumentTypeView(generics.RetrieveDestroyAPIView):
|
||||
RESEARCH: Move this kind of methods to the serializer instead it that
|
||||
ability becomes available in Django REST framework
|
||||
"""
|
||||
|
||||
self.get_workflow().document_types.remove(instance)
|
||||
|
||||
|
||||
class APIWorkflowListView(generics.ListCreateAPIView):
|
||||
"""
|
||||
get: Returns a list of all the workflows.
|
||||
post: Create a new workflow.
|
||||
"""
|
||||
filter_backends = (MayanObjectPermissionsFilter,)
|
||||
mayan_object_permissions = {'GET': (permission_workflow_view,)}
|
||||
mayan_view_permissions = {'POST': (permission_workflow_create,)}
|
||||
permission_classes = (MayanPermission,)
|
||||
queryset = Workflow.objects.all()
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Returns a list of all the workflows.
|
||||
"""
|
||||
return super(APIWorkflowListView, self).get(*args, **kwargs)
|
||||
|
||||
def get_serializer(self, *args, **kwargs):
|
||||
if not self.request:
|
||||
return None
|
||||
@@ -228,14 +195,14 @@ class APIWorkflowListView(generics.ListCreateAPIView):
|
||||
else:
|
||||
return WritableWorkflowSerializer
|
||||
|
||||
def post(self, *args, **kwargs):
|
||||
"""
|
||||
Create a new workflow.
|
||||
"""
|
||||
return super(APIWorkflowListView, self).post(*args, **kwargs)
|
||||
|
||||
|
||||
class APIWorkflowView(generics.RetrieveUpdateDestroyAPIView):
|
||||
"""
|
||||
delete: Delete the selected workflow.
|
||||
get: Return the details of the selected workflow.
|
||||
patch: Edit the selected workflow.
|
||||
put: Edit the selected workflow.
|
||||
"""
|
||||
filter_backends = (MayanObjectPermissionsFilter,)
|
||||
mayan_object_permissions = {
|
||||
'DELETE': (permission_workflow_delete,),
|
||||
@@ -245,20 +212,6 @@ class APIWorkflowView(generics.RetrieveUpdateDestroyAPIView):
|
||||
}
|
||||
queryset = Workflow.objects.all()
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
"""
|
||||
Delete the selected workflow.
|
||||
"""
|
||||
|
||||
return super(APIWorkflowView, self).delete(*args, **kwargs)
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Return the details of the selected workflow.
|
||||
"""
|
||||
|
||||
return super(APIWorkflowView, self).get(*args, **kwargs)
|
||||
|
||||
def get_serializer(self, *args, **kwargs):
|
||||
if not self.request:
|
||||
return None
|
||||
@@ -271,33 +224,17 @@ class APIWorkflowView(generics.RetrieveUpdateDestroyAPIView):
|
||||
else:
|
||||
return WritableWorkflowSerializer
|
||||
|
||||
def patch(self, *args, **kwargs):
|
||||
"""
|
||||
Edit the selected workflow.
|
||||
"""
|
||||
|
||||
return super(APIWorkflowView, self).patch(*args, **kwargs)
|
||||
|
||||
def put(self, *args, **kwargs):
|
||||
"""
|
||||
Edit the selected workflow.
|
||||
"""
|
||||
|
||||
return super(APIWorkflowView, self).put(*args, **kwargs)
|
||||
|
||||
|
||||
# Workflow state views
|
||||
|
||||
|
||||
class APIWorkflowStateListView(generics.ListCreateAPIView):
|
||||
"""
|
||||
get: Returns a list of all the workflow states.
|
||||
post: Create a new workflow state.
|
||||
"""
|
||||
serializer_class = WorkflowStateSerializer
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Returns a list of all the workflow states.
|
||||
"""
|
||||
return super(APIWorkflowStateListView, self).get(*args, **kwargs)
|
||||
|
||||
def get_queryset(self):
|
||||
return self.get_workflow().states.all()
|
||||
|
||||
@@ -330,31 +267,17 @@ class APIWorkflowStateListView(generics.ListCreateAPIView):
|
||||
|
||||
return workflow
|
||||
|
||||
def post(self, *args, **kwargs):
|
||||
"""
|
||||
Create a new workflow state.
|
||||
"""
|
||||
return super(APIWorkflowStateListView, self).post(*args, **kwargs)
|
||||
|
||||
|
||||
class APIWorkflowStateView(generics.RetrieveUpdateDestroyAPIView):
|
||||
"""
|
||||
delete: Delete the selected workflow state.
|
||||
get: Return the details of the selected workflow state.
|
||||
patch: Edit the selected workflow state.
|
||||
put: Edit the selected workflow state.
|
||||
"""
|
||||
lookup_url_kwarg = 'state_pk'
|
||||
serializer_class = WorkflowStateSerializer
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
"""
|
||||
Delete the selected workflow state.
|
||||
"""
|
||||
|
||||
return super(APIWorkflowStateView, self).delete(*args, **kwargs)
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Return the details of the selected workflow state.
|
||||
"""
|
||||
|
||||
return super(APIWorkflowStateView, self).get(*args, **kwargs)
|
||||
|
||||
def get_queryset(self):
|
||||
return self.get_workflow().states.all()
|
||||
|
||||
@@ -387,31 +310,15 @@ class APIWorkflowStateView(generics.RetrieveUpdateDestroyAPIView):
|
||||
|
||||
return workflow
|
||||
|
||||
def patch(self, *args, **kwargs):
|
||||
"""
|
||||
Edit the selected workflow state.
|
||||
"""
|
||||
|
||||
return super(APIWorkflowStateView, self).patch(*args, **kwargs)
|
||||
|
||||
def put(self, *args, **kwargs):
|
||||
"""
|
||||
Edit the selected workflow state.
|
||||
"""
|
||||
|
||||
return super(APIWorkflowStateView, self).put(*args, **kwargs)
|
||||
|
||||
|
||||
# Workflow transition views
|
||||
|
||||
|
||||
class APIWorkflowTransitionListView(generics.ListCreateAPIView):
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Returns a list of all the workflow transitions.
|
||||
"""
|
||||
return super(APIWorkflowTransitionListView, self).get(*args, **kwargs)
|
||||
|
||||
"""
|
||||
get: Returns a list of all the workflow transitions.
|
||||
post: Create a new workflow transition.
|
||||
"""
|
||||
def get_queryset(self):
|
||||
return self.get_workflow().transitions.all()
|
||||
|
||||
@@ -456,30 +363,16 @@ class APIWorkflowTransitionListView(generics.ListCreateAPIView):
|
||||
|
||||
return workflow
|
||||
|
||||
def post(self, *args, **kwargs):
|
||||
"""
|
||||
Create a new workflow transition.
|
||||
"""
|
||||
return super(APIWorkflowTransitionListView, self).post(*args, **kwargs)
|
||||
|
||||
|
||||
class APIWorkflowTransitionView(generics.RetrieveUpdateDestroyAPIView):
|
||||
"""
|
||||
delete: Delete the selected workflow transition.
|
||||
get: Return the details of the selected workflow transition.
|
||||
patch: Edit the selected workflow transition.
|
||||
put: Edit the selected workflow transition.
|
||||
"""
|
||||
lookup_url_kwarg = 'transition_pk'
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
"""
|
||||
Delete the selected workflow transition.
|
||||
"""
|
||||
|
||||
return super(APIWorkflowTransitionView, self).delete(*args, **kwargs)
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Return the details of the selected workflow transition.
|
||||
"""
|
||||
|
||||
return super(APIWorkflowTransitionView, self).get(*args, **kwargs)
|
||||
|
||||
def get_queryset(self):
|
||||
return self.get_workflow().transitions.all()
|
||||
|
||||
@@ -524,37 +417,20 @@ class APIWorkflowTransitionView(generics.RetrieveUpdateDestroyAPIView):
|
||||
|
||||
return workflow
|
||||
|
||||
def patch(self, *args, **kwargs):
|
||||
"""
|
||||
Edit the selected workflow transition.
|
||||
"""
|
||||
|
||||
return super(APIWorkflowTransitionView, self).patch(*args, **kwargs)
|
||||
|
||||
def put(self, *args, **kwargs):
|
||||
"""
|
||||
Edit the selected workflow transition.
|
||||
"""
|
||||
|
||||
return super(APIWorkflowTransitionView, self).put(*args, **kwargs)
|
||||
|
||||
|
||||
# Document workflow views
|
||||
|
||||
|
||||
class APIWorkflowInstanceListView(generics.ListAPIView):
|
||||
"""
|
||||
get: Returns a list of all the document workflows.
|
||||
"""
|
||||
filter_backends = (MayanObjectPermissionsFilter,)
|
||||
serializer_class = WorkflowInstanceSerializer
|
||||
mayan_object_permissions = {
|
||||
'GET': (permission_workflow_view,),
|
||||
}
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Returns a list of all the document workflows.
|
||||
"""
|
||||
return super(APIWorkflowInstanceListView, self).get(*args, **kwargs)
|
||||
|
||||
def get_document(self):
|
||||
document = get_object_or_404(Document, pk=self.kwargs['pk'])
|
||||
|
||||
@@ -570,6 +446,9 @@ class APIWorkflowInstanceListView(generics.ListAPIView):
|
||||
|
||||
|
||||
class APIWorkflowInstanceView(generics.RetrieveAPIView):
|
||||
"""
|
||||
get: Return the details of the selected document workflow.
|
||||
"""
|
||||
filter_backends = (MayanObjectPermissionsFilter,)
|
||||
lookup_url_kwarg = 'workflow_pk'
|
||||
mayan_object_permissions = {
|
||||
@@ -577,13 +456,6 @@ class APIWorkflowInstanceView(generics.RetrieveAPIView):
|
||||
}
|
||||
serializer_class = WorkflowInstanceSerializer
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Return the details of the selected document workflow.
|
||||
"""
|
||||
|
||||
return super(APIWorkflowInstanceView, self).get(*args, **kwargs)
|
||||
|
||||
def get_document(self):
|
||||
document = get_object_or_404(Document, pk=self.kwargs['pk'])
|
||||
|
||||
@@ -599,14 +471,10 @@ class APIWorkflowInstanceView(generics.RetrieveAPIView):
|
||||
|
||||
|
||||
class APIWorkflowInstanceLogEntryListView(generics.ListCreateAPIView):
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Returns a list of all the document workflows log entries.
|
||||
"""
|
||||
return super(APIWorkflowInstanceLogEntryListView, self).get(
|
||||
*args, **kwargs
|
||||
)
|
||||
|
||||
"""
|
||||
get: Returns a list of all the document workflows log entries.
|
||||
post: Transition a document workflow by creating a new document workflow log entry.
|
||||
"""
|
||||
def get_document(self):
|
||||
document = get_object_or_404(Document, pk=self.kwargs['pk'])
|
||||
|
||||
@@ -660,12 +528,3 @@ class APIWorkflowInstanceLogEntryListView(generics.ListCreateAPIView):
|
||||
)
|
||||
|
||||
return workflow
|
||||
|
||||
def post(self, *args, **kwargs):
|
||||
"""
|
||||
Transition a document workflow by creating a new document workflow
|
||||
log entry.
|
||||
"""
|
||||
return super(
|
||||
APIWorkflowInstanceLogEntryListView, self
|
||||
).post(*args, **kwargs)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -14,17 +14,8 @@ from .serializers import SearchModelSerializer
|
||||
|
||||
class APISearchView(SearchModelMixin, generics.ListAPIView):
|
||||
"""
|
||||
Perform a search operation
|
||||
---
|
||||
GET:
|
||||
omit_serializer: true
|
||||
parameters:
|
||||
- name: q
|
||||
paramType: query
|
||||
type: string
|
||||
description: Term that will be used for the search.
|
||||
get: Perform a search operation
|
||||
"""
|
||||
|
||||
filter_backends = (MayanObjectPermissionsFilter,)
|
||||
|
||||
def get_queryset(self):
|
||||
@@ -55,17 +46,8 @@ class APISearchView(SearchModelMixin, generics.ListAPIView):
|
||||
|
||||
class APIAdvancedSearchView(SearchModelMixin, generics.ListAPIView):
|
||||
"""
|
||||
Perform an advanced search operation
|
||||
---
|
||||
GET:
|
||||
omit_serializer: true
|
||||
parameters:
|
||||
- name: _match_all
|
||||
paramType: query
|
||||
type: string
|
||||
description: When checked, only results that match all fields will be returned. When unchecked results that match at least one field will be returned. Possible values are "on" or "off"
|
||||
get: Perform an advanced search operation
|
||||
"""
|
||||
|
||||
filter_backends = (MayanObjectPermissionsFilter,)
|
||||
|
||||
def get_queryset(self):
|
||||
@@ -103,12 +85,8 @@ class APIAdvancedSearchView(SearchModelMixin, generics.ListAPIView):
|
||||
|
||||
|
||||
class APISearchModelList(generics.ListAPIView):
|
||||
"""
|
||||
get: Returns a list of all the available search models.
|
||||
"""
|
||||
serializer_class = SearchModelSerializer
|
||||
queryset = SearchModel.all()
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Returns a list of all the available search models.
|
||||
"""
|
||||
|
||||
return super(APISearchModelList, self).get(*args, **kwargs)
|
||||
|
||||
@@ -21,9 +21,8 @@ from .serializers import (
|
||||
|
||||
class APIObjectEventListView(generics.ListAPIView):
|
||||
"""
|
||||
Return a list of events for the specified object.
|
||||
get: Return a list of events for the specified object.
|
||||
"""
|
||||
|
||||
serializer_class = EventSerializer
|
||||
|
||||
def get_object(self):
|
||||
@@ -52,7 +51,7 @@ class APIObjectEventListView(generics.ListAPIView):
|
||||
|
||||
class APIEventTypeNamespaceDetailView(generics.RetrieveAPIView):
|
||||
"""
|
||||
Returns the details of an event type namespace.
|
||||
get: Returns the details of an event type namespace.
|
||||
"""
|
||||
serializer_class = EventTypeNamespaceSerializer
|
||||
|
||||
@@ -65,9 +64,8 @@ class APIEventTypeNamespaceDetailView(generics.RetrieveAPIView):
|
||||
|
||||
class APIEventTypeNamespaceListView(generics.ListAPIView):
|
||||
"""
|
||||
Returns a list of all the available event type namespaces.
|
||||
get: Returns a list of all the available event type namespaces.
|
||||
"""
|
||||
|
||||
serializer_class = EventTypeNamespaceSerializer
|
||||
queryset = EventTypeNamespace.all()
|
||||
|
||||
@@ -81,9 +79,8 @@ class APIEventTypeNamespaceListView(generics.ListAPIView):
|
||||
|
||||
class APIEventTypeNamespaceEventTypeListView(generics.ListAPIView):
|
||||
"""
|
||||
Returns a list of all the available event types from a namespaces.
|
||||
get: Returns a list of all the available event types from a namespaces.
|
||||
"""
|
||||
|
||||
serializer_class = EventTypeSerializer
|
||||
|
||||
def get_queryset(self):
|
||||
@@ -104,9 +101,8 @@ class APIEventTypeNamespaceEventTypeListView(generics.ListAPIView):
|
||||
|
||||
class APIEventTypeListView(generics.ListAPIView):
|
||||
"""
|
||||
Returns a list of all the available event types.
|
||||
get: Returns a list of all the available event types.
|
||||
"""
|
||||
|
||||
serializer_class = EventTypeSerializer
|
||||
queryset = EventType.all()
|
||||
|
||||
@@ -120,9 +116,8 @@ class APIEventTypeListView(generics.ListAPIView):
|
||||
|
||||
class APIEventListView(generics.ListAPIView):
|
||||
"""
|
||||
Returns a list of all the available events.
|
||||
get: Returns a list of all the available events.
|
||||
"""
|
||||
|
||||
mayan_view_permissions = {'GET': (permission_events_view,)}
|
||||
permission_classes = (MayanPermission,)
|
||||
queryset = Action.objects.all()
|
||||
@@ -138,7 +133,7 @@ class APIEventListView(generics.ListAPIView):
|
||||
|
||||
class APINotificationListView(generics.ListAPIView):
|
||||
"""
|
||||
Return a list of notifications for the current user.
|
||||
get: Return a list of notifications for the current user.
|
||||
"""
|
||||
serializer_class = NotificationSerializer
|
||||
|
||||
|
||||
@@ -23,19 +23,14 @@ from .serializers import (
|
||||
|
||||
|
||||
class APIResolvedSmartLinkDocumentListView(generics.ListAPIView):
|
||||
"""
|
||||
get: Returns a list of the smart link documents that apply to the document.
|
||||
"""
|
||||
filter_backends = (MayanObjectPermissionsFilter,)
|
||||
mayan_object_permissions = {'GET': (permission_document_view,)}
|
||||
permission_classes = (MayanPermission,)
|
||||
serializer_class = ResolvedSmartLinkDocumentSerializer
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Returns a list of the smart link documents that apply to the document.
|
||||
"""
|
||||
return super(APIResolvedSmartLinkDocumentListView, self).get(
|
||||
*args, **kwargs
|
||||
)
|
||||
|
||||
def get_document(self):
|
||||
document = get_object_or_404(Document, pk=self.kwargs['pk'])
|
||||
|
||||
@@ -81,18 +76,15 @@ class APIResolvedSmartLinkDocumentListView(generics.ListAPIView):
|
||||
|
||||
|
||||
class APIResolvedSmartLinkView(generics.RetrieveAPIView):
|
||||
"""
|
||||
get: Return the details of the selected resolved smart link.
|
||||
"""
|
||||
filter_backends = (MayanObjectPermissionsFilter,)
|
||||
lookup_url_kwarg = 'smart_link_pk'
|
||||
mayan_object_permissions = {'GET': (permission_smart_link_view,)}
|
||||
permission_classes = (MayanPermission,)
|
||||
serializer_class = ResolvedSmartLinkSerializer
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Return the details of the selected resolved smart link.
|
||||
"""
|
||||
return super(APIResolvedSmartLinkView, self).get(*args, **kwargs)
|
||||
|
||||
def get_document(self):
|
||||
document = get_object_or_404(Document, pk=self.kwargs['pk'])
|
||||
|
||||
@@ -122,17 +114,14 @@ class APIResolvedSmartLinkView(generics.RetrieveAPIView):
|
||||
|
||||
|
||||
class APIResolvedSmartLinkListView(generics.ListAPIView):
|
||||
"""
|
||||
get: Returns a list of the smart links that apply to the document.
|
||||
"""
|
||||
filter_backends = (MayanObjectPermissionsFilter,)
|
||||
mayan_object_permissions = {'GET': (permission_smart_link_view,)}
|
||||
permission_classes = (MayanPermission,)
|
||||
serializer_class = ResolvedSmartLinkSerializer
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Returns a list of the smart links that apply to the document.
|
||||
"""
|
||||
return super(APIResolvedSmartLinkListView, self).get(*args, **kwargs)
|
||||
|
||||
def get_document(self):
|
||||
document = get_object_or_404(Document, pk=self.kwargs['pk'])
|
||||
|
||||
@@ -164,14 +153,12 @@ class APIResolvedSmartLinkListView(generics.ListAPIView):
|
||||
|
||||
|
||||
class APISmartLinkConditionListView(generics.ListCreateAPIView):
|
||||
"""
|
||||
get: Returns a list of all the smart link conditions.
|
||||
post: Create a new smart link condition.
|
||||
"""
|
||||
serializer_class = SmartLinkConditionSerializer
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Returns a list of all the smart link conditions.
|
||||
"""
|
||||
return super(APISmartLinkConditionListView, self).get(*args, **kwargs)
|
||||
|
||||
def get_queryset(self):
|
||||
return self.get_smart_link().conditions.all()
|
||||
|
||||
@@ -204,31 +191,17 @@ class APISmartLinkConditionListView(generics.ListCreateAPIView):
|
||||
|
||||
return smart_link
|
||||
|
||||
def post(self, *args, **kwargs):
|
||||
"""
|
||||
Create a new smart link condition.
|
||||
"""
|
||||
return super(APISmartLinkConditionListView, self).post(*args, **kwargs)
|
||||
|
||||
|
||||
class APISmartLinkConditionView(generics.RetrieveUpdateDestroyAPIView):
|
||||
"""
|
||||
delete: Delete the selected smart link condition.
|
||||
get: Return the details of the selected smart link condition.
|
||||
patch: Edit the selected smart link condition.
|
||||
put: Edit the selected smart link condition.
|
||||
"""
|
||||
lookup_url_kwarg = 'condition_pk'
|
||||
serializer_class = SmartLinkConditionSerializer
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
"""
|
||||
Delete the selected smart link condition.
|
||||
"""
|
||||
|
||||
return super(APISmartLinkConditionView, self).delete(*args, **kwargs)
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Return the details of the selected smart link condition.
|
||||
"""
|
||||
|
||||
return super(APISmartLinkConditionView, self).get(*args, **kwargs)
|
||||
|
||||
def get_queryset(self):
|
||||
return self.get_smart_link().conditions.all()
|
||||
|
||||
@@ -261,35 +234,18 @@ class APISmartLinkConditionView(generics.RetrieveUpdateDestroyAPIView):
|
||||
|
||||
return smart_link
|
||||
|
||||
def patch(self, *args, **kwargs):
|
||||
"""
|
||||
Edit the selected smart link condition.
|
||||
"""
|
||||
|
||||
return super(APISmartLinkConditionView, self).patch(*args, **kwargs)
|
||||
|
||||
def put(self, *args, **kwargs):
|
||||
"""
|
||||
Edit the selected smart link condition.
|
||||
"""
|
||||
|
||||
return super(APISmartLinkConditionView, self).put(*args, **kwargs)
|
||||
|
||||
|
||||
class APISmartLinkListView(generics.ListCreateAPIView):
|
||||
"""
|
||||
get: Returns a list of all the smart links.
|
||||
post: Create a new smart link.
|
||||
"""
|
||||
filter_backends = (MayanObjectPermissionsFilter,)
|
||||
mayan_object_permissions = {'GET': (permission_smart_link_view,)}
|
||||
mayan_view_permissions = {'POST': (permission_smart_link_create,)}
|
||||
permission_classes = (MayanPermission,)
|
||||
queryset = SmartLink.objects.all()
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Returns a list of all the smart links.
|
||||
"""
|
||||
|
||||
return super(APISmartLinkListView, self).get(*args, **kwargs)
|
||||
|
||||
def get_serializer(self, *args, **kwargs):
|
||||
if not self.request:
|
||||
return None
|
||||
@@ -302,15 +258,14 @@ class APISmartLinkListView(generics.ListCreateAPIView):
|
||||
else:
|
||||
return WritableSmartLinkSerializer
|
||||
|
||||
def post(self, *args, **kwargs):
|
||||
"""
|
||||
Create a new smart link.
|
||||
"""
|
||||
|
||||
return super(APISmartLinkListView, self).post(*args, **kwargs)
|
||||
|
||||
|
||||
class APISmartLinkView(generics.RetrieveUpdateDestroyAPIView):
|
||||
"""
|
||||
delete: Delete the selected smart link.
|
||||
get: Return the details of the selected smart link.
|
||||
patch: Edit the selected smart link.
|
||||
put: Edit the selected smart link.
|
||||
"""
|
||||
filter_backends = (MayanObjectPermissionsFilter,)
|
||||
mayan_object_permissions = {
|
||||
'DELETE': (permission_smart_link_delete,),
|
||||
@@ -320,20 +275,6 @@ class APISmartLinkView(generics.RetrieveUpdateDestroyAPIView):
|
||||
}
|
||||
queryset = SmartLink.objects.all()
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
"""
|
||||
Delete the selected smart link.
|
||||
"""
|
||||
|
||||
return super(APISmartLinkView, self).delete(*args, **kwargs)
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Return the details of the selected smart ink.
|
||||
"""
|
||||
|
||||
return super(APISmartLinkView, self).get(*args, **kwargs)
|
||||
|
||||
def get_serializer(self, *args, **kwargs):
|
||||
if not self.request:
|
||||
return None
|
||||
@@ -345,17 +286,3 @@ class APISmartLinkView(generics.RetrieveUpdateDestroyAPIView):
|
||||
return SmartLinkSerializer
|
||||
else:
|
||||
return WritableSmartLinkSerializer
|
||||
|
||||
def patch(self, *args, **kwargs):
|
||||
"""
|
||||
Edit the selected smart link.
|
||||
"""
|
||||
|
||||
return super(APISmartLinkView, self).patch(*args, **kwargs)
|
||||
|
||||
def put(self, *args, **kwargs):
|
||||
"""
|
||||
Edit the selected smart link.
|
||||
"""
|
||||
|
||||
return super(APISmartLinkView, self).put(*args, **kwargs)
|
||||
|
||||
@@ -14,6 +14,9 @@ from .serializers import DocumentPageOCRContentSerializer
|
||||
|
||||
|
||||
class APIDocumentOCRView(generics.GenericAPIView):
|
||||
"""
|
||||
post: Submit a document for OCR.
|
||||
"""
|
||||
mayan_object_permissions = {
|
||||
'POST': (permission_ocr_document,)
|
||||
}
|
||||
@@ -27,20 +30,14 @@ class APIDocumentOCRView(generics.GenericAPIView):
|
||||
return None
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
"""
|
||||
Submit a document for OCR.
|
||||
---
|
||||
omit_serializer: true
|
||||
responseMessages:
|
||||
- code: 202
|
||||
message: Accepted
|
||||
"""
|
||||
|
||||
self.get_object().submit_for_ocr()
|
||||
return Response(status=status.HTTP_202_ACCEPTED)
|
||||
|
||||
|
||||
class APIDocumentVersionOCRView(generics.GenericAPIView):
|
||||
"""
|
||||
post: Submit a document version for OCR.
|
||||
"""
|
||||
lookup_url_kwarg = 'version_pk'
|
||||
mayan_object_permissions = {
|
||||
'POST': (permission_ocr_document,)
|
||||
@@ -61,22 +58,13 @@ class APIDocumentVersionOCRView(generics.GenericAPIView):
|
||||
return None
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
"""
|
||||
Submit a document version for OCR.
|
||||
---
|
||||
omit_serializer: true
|
||||
responseMessages:
|
||||
- code: 202
|
||||
message: Accepted
|
||||
"""
|
||||
|
||||
self.get_object().submit_for_ocr()
|
||||
return Response(status=status.HTTP_202_ACCEPTED)
|
||||
|
||||
|
||||
class APIDocumentPageOCRContentView(generics.RetrieveAPIView):
|
||||
"""
|
||||
Returns the OCR content of the selected document page.
|
||||
get: Returns the OCR content of the selected document page.
|
||||
"""
|
||||
lookup_url_kwarg = 'page_pk'
|
||||
mayan_object_permissions = {
|
||||
|
||||
@@ -17,31 +17,24 @@ from .serializers import (
|
||||
|
||||
|
||||
class APIPermissionList(generics.ListAPIView):
|
||||
"""
|
||||
get: Returns a list of all the available permissions.
|
||||
"""
|
||||
serializer_class = PermissionSerializer
|
||||
queryset = Permission.all()
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Returns a list of all the available permissions.
|
||||
"""
|
||||
|
||||
return super(APIPermissionList, self).get(*args, **kwargs)
|
||||
|
||||
|
||||
class APIRoleListView(generics.ListCreateAPIView):
|
||||
"""
|
||||
get: Returns a list of all the roles.
|
||||
post: Create a new role.
|
||||
"""
|
||||
filter_backends = (MayanObjectPermissionsFilter,)
|
||||
mayan_object_permissions = {'GET': (permission_role_view,)}
|
||||
mayan_view_permissions = {'POST': (permission_role_create,)}
|
||||
permission_classes = (MayanPermission,)
|
||||
queryset = Role.objects.all()
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Returns a list of all the roles.
|
||||
"""
|
||||
|
||||
return super(APIRoleListView, self).get(*args, **kwargs)
|
||||
|
||||
def get_serializer(self, *args, **kwargs):
|
||||
if not self.request:
|
||||
return None
|
||||
@@ -54,15 +47,14 @@ class APIRoleListView(generics.ListCreateAPIView):
|
||||
elif self.request.method == 'POST':
|
||||
return WritableRoleSerializer
|
||||
|
||||
def post(self, *args, **kwargs):
|
||||
"""
|
||||
Create a new role.
|
||||
"""
|
||||
|
||||
return super(APIRoleListView, self).post(*args, **kwargs)
|
||||
|
||||
|
||||
class APIRoleView(generics.RetrieveUpdateDestroyAPIView):
|
||||
"""
|
||||
delete: Delete the selected role.
|
||||
get: Return the details of the selected role.
|
||||
patch: Edit the selected role.
|
||||
put: Edit the selected role.
|
||||
"""
|
||||
mayan_object_permissions = {
|
||||
'GET': (permission_role_view,),
|
||||
'PUT': (permission_role_edit,),
|
||||
@@ -72,20 +64,6 @@ class APIRoleView(generics.RetrieveUpdateDestroyAPIView):
|
||||
permission_classes = (MayanPermission,)
|
||||
queryset = Role.objects.all()
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
"""
|
||||
Delete the selected role.
|
||||
"""
|
||||
|
||||
return super(APIRoleView, self).delete(*args, **kwargs)
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Return the details of the selected role.
|
||||
"""
|
||||
|
||||
return super(APIRoleView, self).get(*args, **kwargs)
|
||||
|
||||
def get_serializer(self, *args, **kwargs):
|
||||
if not self.request:
|
||||
return None
|
||||
@@ -97,17 +75,3 @@ class APIRoleView(generics.RetrieveUpdateDestroyAPIView):
|
||||
return RoleSerializer
|
||||
elif self.request.method in ('PATCH', 'PUT'):
|
||||
return WritableRoleSerializer
|
||||
|
||||
def patch(self, *args, **kwargs):
|
||||
"""
|
||||
Edit the selected role.
|
||||
"""
|
||||
|
||||
return super(APIRoleView, self).patch(*args, **kwargs)
|
||||
|
||||
def put(self, *args, **kwargs):
|
||||
"""
|
||||
Edit the selected role.
|
||||
"""
|
||||
|
||||
return super(APIRoleView, self).put(*args, **kwargs)
|
||||
|
||||
@@ -15,7 +15,7 @@ class APIRoot(APIView):
|
||||
|
||||
def get(self, request, format=None):
|
||||
"""
|
||||
Return a list of all users.
|
||||
get: Return a list of all endpoints.
|
||||
"""
|
||||
endpoint_enumerator = EndpointEnumerator()
|
||||
|
||||
@@ -32,5 +32,4 @@ class BrowseableObtainAuthToken(ObtainAuthToken):
|
||||
"""
|
||||
Obtain an API authentication token.
|
||||
"""
|
||||
|
||||
renderer_classes = (renderers.BrowsableAPIRenderer, renderers.JSONRenderer)
|
||||
|
||||
@@ -13,7 +13,7 @@ from .serializers import StagingFolderFileSerializer, StagingFolderSerializer
|
||||
|
||||
class APIStagingSourceFileView(generics.GenericAPIView):
|
||||
"""
|
||||
Details of the selected staging file.
|
||||
get: Details of the selected staging file.
|
||||
"""
|
||||
serializer_class = StagingFolderFileSerializer
|
||||
|
||||
@@ -31,7 +31,7 @@ class APIStagingSourceFileView(generics.GenericAPIView):
|
||||
|
||||
class APIStagingSourceListView(generics.ListAPIView):
|
||||
"""
|
||||
Returns a list of all the staging folders and the files they contain.
|
||||
get: Returns a list of all the staging folders and the files they contain.
|
||||
"""
|
||||
|
||||
serializer_class = StagingFolderSerializer
|
||||
@@ -40,7 +40,7 @@ class APIStagingSourceListView(generics.ListAPIView):
|
||||
|
||||
class APIStagingSourceView(generics.RetrieveAPIView):
|
||||
"""
|
||||
Details of the selected staging folders and the files it contains.
|
||||
get: Details of the selected staging folders and the files it contains.
|
||||
"""
|
||||
serializer_class = StagingFolderSerializer
|
||||
queryset = StagingFolderSource.objects.all()
|
||||
@@ -48,17 +48,8 @@ class APIStagingSourceView(generics.RetrieveAPIView):
|
||||
|
||||
class APIStagingSourceFileImageView(generics.RetrieveAPIView):
|
||||
"""
|
||||
Returns an image representation of the selected document.
|
||||
---
|
||||
GET:
|
||||
omit_serializer: true
|
||||
parameters:
|
||||
- name: size
|
||||
description: 'x' seprated width and height of the desired image representation.
|
||||
paramType: query
|
||||
type: number
|
||||
get: Returns an image representation of the selected document.
|
||||
"""
|
||||
|
||||
def get_serializer(self, *args, **kwargs):
|
||||
return None
|
||||
|
||||
|
||||
@@ -25,6 +25,10 @@ from .serializers import (
|
||||
|
||||
|
||||
class APITagListView(generics.ListCreateAPIView):
|
||||
"""
|
||||
get: Returns a list of all the tags.
|
||||
post: Create a new tag.
|
||||
"""
|
||||
filter_backends = (MayanObjectPermissionsFilter,)
|
||||
mayan_object_permissions = {'GET': (permission_tag_view,)}
|
||||
mayan_view_permissions = {'POST': (permission_tag_create,)}
|
||||
@@ -43,22 +47,14 @@ class APITagListView(generics.ListCreateAPIView):
|
||||
elif self.request.method == 'POST':
|
||||
return WritableTagSerializer
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Returns a list of all the tags.
|
||||
"""
|
||||
|
||||
return super(APITagListView, self).get(*args, **kwargs)
|
||||
|
||||
def post(self, *args, **kwargs):
|
||||
"""
|
||||
Create a new tag.
|
||||
"""
|
||||
|
||||
return super(APITagListView, self).post(*args, **kwargs)
|
||||
|
||||
|
||||
class APITagView(generics.RetrieveUpdateDestroyAPIView):
|
||||
"""
|
||||
delete: Delete the selected tag.
|
||||
get: Return the details of the selected tag.
|
||||
patch: Edit the selected tag.
|
||||
put: Edit the selected tag.
|
||||
"""
|
||||
filter_backends = (MayanObjectPermissionsFilter,)
|
||||
mayan_object_permissions = {
|
||||
'DELETE': (permission_tag_delete,),
|
||||
@@ -68,20 +64,6 @@ class APITagView(generics.RetrieveUpdateDestroyAPIView):
|
||||
}
|
||||
queryset = Tag.objects.all()
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
"""
|
||||
Delete the selected tag.
|
||||
"""
|
||||
|
||||
return super(APITagView, self).delete(*args, **kwargs)
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Return the details of the selected tag.
|
||||
"""
|
||||
|
||||
return super(APITagView, self).get(*args, **kwargs)
|
||||
|
||||
def get_serializer(self, *args, **kwargs):
|
||||
if not self.request:
|
||||
return None
|
||||
@@ -94,26 +76,11 @@ class APITagView(generics.RetrieveUpdateDestroyAPIView):
|
||||
else:
|
||||
return WritableTagSerializer
|
||||
|
||||
def patch(self, *args, **kwargs):
|
||||
"""
|
||||
Edit the selected tag.
|
||||
"""
|
||||
|
||||
return super(APITagView, self).patch(*args, **kwargs)
|
||||
|
||||
def put(self, *args, **kwargs):
|
||||
"""
|
||||
Edit the selected tag.
|
||||
"""
|
||||
|
||||
return super(APITagView, self).put(*args, **kwargs)
|
||||
|
||||
|
||||
class APITagDocumentListView(generics.ListAPIView):
|
||||
"""
|
||||
Returns a list of all the documents tagged by a particular tag.
|
||||
get: Returns a list of all the documents tagged by a particular tag.
|
||||
"""
|
||||
|
||||
filter_backends = (MayanObjectPermissionsFilter,)
|
||||
mayan_object_permissions = {'GET': (permission_document_view,)}
|
||||
serializer_class = DocumentSerializer
|
||||
@@ -129,19 +96,16 @@ class APITagDocumentListView(generics.ListAPIView):
|
||||
|
||||
|
||||
class APIDocumentTagListView(generics.ListCreateAPIView):
|
||||
"""
|
||||
get: Returns a list of all the tags attached to a document.
|
||||
post: Attach a tag to a document.
|
||||
"""
|
||||
filter_backends = (MayanObjectPermissionsFilter,)
|
||||
mayan_object_permissions = {
|
||||
'GET': (permission_tag_view,),
|
||||
'POST': (permission_tag_attach,)
|
||||
}
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Returns a list of all the tags attached to a document.
|
||||
"""
|
||||
|
||||
return super(APIDocumentTagListView, self).get(*args, **kwargs)
|
||||
|
||||
def get_document(self):
|
||||
return get_object_or_404(Document, pk=self.kwargs['document_pk'])
|
||||
|
||||
@@ -184,17 +148,12 @@ class APIDocumentTagListView(generics.ListCreateAPIView):
|
||||
def perform_create(self, serializer):
|
||||
serializer.save(document=self.get_document())
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
"""
|
||||
Attach a tag to a document.
|
||||
"""
|
||||
|
||||
return super(
|
||||
APIDocumentTagListView, self
|
||||
).post(request, *args, **kwargs)
|
||||
|
||||
|
||||
class APIDocumentTagView(generics.RetrieveDestroyAPIView):
|
||||
"""
|
||||
delete: Remove a tag from the selected document.
|
||||
get: Returns the details of the selected document tag.
|
||||
"""
|
||||
filter_backends = (MayanObjectPermissionsFilter,)
|
||||
mayan_object_permissions = {
|
||||
'GET': (permission_tag_view,),
|
||||
@@ -202,22 +161,6 @@ class APIDocumentTagView(generics.RetrieveDestroyAPIView):
|
||||
}
|
||||
serializer_class = DocumentTagSerializer
|
||||
|
||||
def delete(self, request, *args, **kwargs):
|
||||
"""
|
||||
Remove a tag from the selected document.
|
||||
"""
|
||||
|
||||
return super(
|
||||
APIDocumentTagView, self
|
||||
).delete(request, *args, **kwargs)
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Returns the details of the selected document tag.
|
||||
"""
|
||||
|
||||
return super(APIDocumentTagView, self).get(*args, **kwargs)
|
||||
|
||||
def get_document(self):
|
||||
document = get_object_or_404(Document, pk=self.kwargs['document_pk'])
|
||||
|
||||
|
||||
@@ -21,41 +21,23 @@ from .serializers import (
|
||||
|
||||
|
||||
class APICurrentUserView(generics.RetrieveUpdateDestroyAPIView):
|
||||
"""
|
||||
delete: Delete the current user.
|
||||
get: Return the details of the current user.
|
||||
patch: Partially edit the current user.
|
||||
put: Edit the current user.
|
||||
"""
|
||||
serializer_class = UserSerializer
|
||||
|
||||
def get_object(self):
|
||||
return self.request.user
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
"""
|
||||
Delete the current user.
|
||||
"""
|
||||
|
||||
return super(APICurrentUserView, self).delete(*args, **kwargs)
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Return the details of the current user.
|
||||
"""
|
||||
|
||||
return super(APICurrentUserView, self).get(*args, **kwargs)
|
||||
|
||||
def patch(self, *args, **kwargs):
|
||||
"""
|
||||
Partially edit the current user.
|
||||
"""
|
||||
|
||||
return super(APICurrentUserView, self).patch(*args, **kwargs)
|
||||
|
||||
def put(self, *args, **kwargs):
|
||||
"""
|
||||
Edit the current user.
|
||||
"""
|
||||
|
||||
return super(APICurrentUserView, self).put(*args, **kwargs)
|
||||
|
||||
|
||||
class APIGroupListView(generics.ListCreateAPIView):
|
||||
"""
|
||||
get: Returns a list of all the groups.
|
||||
post: Create a new group.
|
||||
"""
|
||||
filter_backends = (MayanObjectPermissionsFilter,)
|
||||
mayan_object_permissions = {'GET': (permission_group_view,)}
|
||||
mayan_view_permissions = {'POST': (permission_group_create,)}
|
||||
@@ -63,22 +45,14 @@ class APIGroupListView(generics.ListCreateAPIView):
|
||||
queryset = Group.objects.all()
|
||||
serializer_class = GroupSerializer
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Returns a list of all the groups.
|
||||
"""
|
||||
|
||||
return super(APIGroupListView, self).get(*args, **kwargs)
|
||||
|
||||
def post(self, *args, **kwargs):
|
||||
"""
|
||||
Create a new group.
|
||||
"""
|
||||
|
||||
return super(APIGroupListView, self).post(*args, **kwargs)
|
||||
|
||||
|
||||
class APIGroupView(generics.RetrieveUpdateDestroyAPIView):
|
||||
"""
|
||||
delete: Delete the selected group.
|
||||
get: Return the details of the selected group.
|
||||
patch: Partially edit the selected group.
|
||||
put: Edit the selected group.
|
||||
"""
|
||||
mayan_object_permissions = {
|
||||
'GET': (permission_group_view,),
|
||||
'PUT': (permission_group_edit,),
|
||||
@@ -89,36 +63,12 @@ class APIGroupView(generics.RetrieveUpdateDestroyAPIView):
|
||||
queryset = Group.objects.all()
|
||||
serializer_class = GroupSerializer
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
"""
|
||||
Delete the selected group.
|
||||
"""
|
||||
|
||||
return super(APIGroupView, self).delete(*args, **kwargs)
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Return the details of the selected group.
|
||||
"""
|
||||
|
||||
return super(APIGroupView, self).get(*args, **kwargs)
|
||||
|
||||
def patch(self, *args, **kwargs):
|
||||
"""
|
||||
Partially edit the selected group.
|
||||
"""
|
||||
|
||||
return super(APIGroupView, self).patch(*args, **kwargs)
|
||||
|
||||
def put(self, *args, **kwargs):
|
||||
"""
|
||||
Edit the selected group.
|
||||
"""
|
||||
|
||||
return super(APIGroupView, self).put(*args, **kwargs)
|
||||
|
||||
|
||||
class APIUserListView(generics.ListCreateAPIView):
|
||||
"""
|
||||
get: Returns a list of all the users.
|
||||
post: Create a new user.
|
||||
"""
|
||||
filter_backends = (MayanObjectPermissionsFilter,)
|
||||
mayan_object_permissions = {'GET': (permission_user_view,)}
|
||||
mayan_view_permissions = {'POST': (permission_user_create,)}
|
||||
@@ -126,21 +76,14 @@ class APIUserListView(generics.ListCreateAPIView):
|
||||
queryset = get_user_model().objects.all()
|
||||
serializer_class = UserSerializer
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Returns a list of all the users.
|
||||
"""
|
||||
return super(APIUserListView, self).get(*args, **kwargs)
|
||||
|
||||
def post(self, *args, **kwargs):
|
||||
"""
|
||||
Create a new user.
|
||||
"""
|
||||
|
||||
return super(APIUserListView, self).post(*args, **kwargs)
|
||||
|
||||
|
||||
class APIUserView(generics.RetrieveUpdateDestroyAPIView):
|
||||
"""
|
||||
delete: Delete the selected user.
|
||||
get: Return the details of the selected user.
|
||||
patch: Partially edit the selected user.
|
||||
put: Edit the selected user.
|
||||
"""
|
||||
mayan_object_permissions = {
|
||||
'GET': (permission_user_view,),
|
||||
'PUT': (permission_user_edit,),
|
||||
@@ -151,40 +94,12 @@ class APIUserView(generics.RetrieveUpdateDestroyAPIView):
|
||||
queryset = get_user_model().objects.all()
|
||||
serializer_class = UserSerializer
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
"""
|
||||
Delete the selected user.
|
||||
"""
|
||||
|
||||
return super(APIUserView, self).delete(*args, **kwargs)
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
"""
|
||||
Return the details of the selected user.
|
||||
"""
|
||||
|
||||
return super(APIUserView, self).get(*args, **kwargs)
|
||||
|
||||
def patch(self, *args, **kwargs):
|
||||
"""
|
||||
Partially edit the selected user.
|
||||
"""
|
||||
|
||||
return super(APIUserView, self).patch(*args, **kwargs)
|
||||
|
||||
def put(self, *args, **kwargs):
|
||||
"""
|
||||
Edit the selected user.
|
||||
"""
|
||||
|
||||
return super(APIUserView, self).put(*args, **kwargs)
|
||||
|
||||
|
||||
class APIUserGroupList(generics.ListCreateAPIView):
|
||||
"""
|
||||
Returns a list of all the groups to which an user belongs.
|
||||
get: Returns a list of all the groups to which an user belongs.
|
||||
post: Add a user to a list of groups.
|
||||
"""
|
||||
|
||||
mayan_object_permissions = {
|
||||
'GET': (permission_user_view,),
|
||||
'POST': (permission_user_edit,)
|
||||
@@ -241,9 +156,3 @@ class APIUserGroupList(generics.ListCreateAPIView):
|
||||
|
||||
def perform_create(self, serializer):
|
||||
serializer.save(user=self.get_user(), _user=self.request.user)
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
"""
|
||||
Add a user to a list of groups.
|
||||
"""
|
||||
return super(APIUserGroupList, self).post(request, *args, **kwargs)
|
||||
|
||||
Reference in New Issue
Block a user