Update document comments app

Add keyword arguments to the app links.

Remove use of `raise_404`.

Update URL parameters to use document_id and comment_id.

Signed-off-by: Roberto Rosario <Roberto.Rosario@mayan-edms.com>
This commit is contained in:
Roberto Rosario
2019-01-19 04:08:45 -04:00
parent 53f3261dae
commit 6376445cc4
14 changed files with 49 additions and 64 deletions

View File

@@ -2,7 +2,7 @@ from __future__ import absolute_import, unicode_literals
from rest_framework import generics
from mayan.apps.common.mixins import ExternalObjectViewMixin
from mayan.apps.common.mixins import ExternalObjectMixin
from mayan.apps.documents.models import Document
from .permissions import (
@@ -12,13 +12,13 @@ from .permissions import (
from .serializers import CommentSerializer, WritableCommentSerializer
class APICommentListView(ExternalObjectViewMixin, generics.ListCreateAPIView):
class APICommentListView(ExternalObjectMixin, generics.ListCreateAPIView):
"""
get: Returns a list of all the document comments.
post: Create a new document comment.
"""
external_object_pk_url_kwarg = 'document_pk'
external_object_class = Document
external_object_pk_url_kwarg = 'document_id'
def get_document(self):
return self.get_external_object()
@@ -59,14 +59,14 @@ class APICommentListView(ExternalObjectViewMixin, generics.ListCreateAPIView):
return context
class APICommentView(ExternalObjectViewMixin, generics.RetrieveDestroyAPIView):
class APICommentView(ExternalObjectMixin, generics.RetrieveDestroyAPIView):
"""
delete: Delete the selected document comment.
get: Returns the details of the selected document comment.
"""
external_object_pk_url_kwarg = 'document_pk'
external_object_class = Document
lookup_url_kwarg = 'comment_pk'
external_object_pk_url_kwarg = 'document_id'
lookup_url_kwarg = 'comment_id'
serializer_class = CommentSerializer
def get_document(self):