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

@@ -9,13 +9,13 @@ class CommentsTestMixin(object):
def _create_comment(self, user=None):
self.test_comment = self.document.comments.create(
comment=TEST_COMMENT_TEXT,
user=user or self.user or self.admin_user
user=user or self._test_case_user or self.admin_user
)
def _request_document_comment_add_view(self):
response = self.post(
viewname='comments:comment_add',
kwargs={'document_pk': self.document.pk},
kwargs={'document_id': self.document.pk},
data={'comment': TEST_COMMENT_TEXT}
)
self.test_comment = Comment.objects.filter(
@@ -27,5 +27,5 @@ class CommentsTestMixin(object):
def _request_document_comment_delete_view(self):
return self.post(
viewname='comments:comment_delete',
kwargs={'comment_pk': self.test_comment.pk},
kwargs={'comment_id': self.test_comment.pk},
)

View File

@@ -16,10 +16,6 @@ from .mixins import CommentsTestMixin
class CommentAPITestCase(CommentsTestMixin, DocumentTestMixin, BaseAPITestCase):
def setUp(self):
super(CommentAPITestCase, self).setUp()
self.login_user()
def _request_api_comment_create_view(self):
return self.post(
viewname='rest_api:comment-list',

View File

@@ -13,10 +13,6 @@ from .mixins import CommentsTestMixin
class CommentEventsTestCase(CommentsTestMixin, GenericDocumentViewTestCase):
def setUp(self):
super(CommentEventsTestCase, self).setUp()
self.login_user()
def test_comment_created_event_no_permissions(self):
Action.objects.all().delete()

View File

@@ -12,10 +12,6 @@ from .mixins import CommentsTestMixin
class CommentsViewsTestCase(CommentsTestMixin, GenericDocumentViewTestCase):
def setUp(self):
super(CommentsViewsTestCase, self).setUp()
self.login_user()
def test_document_comment_add_view_no_permission(self):
response = self._request_document_comment_add_view()
self.assertEqual(response.status_code, 404)
@@ -31,7 +27,7 @@ class CommentsViewsTestCase(CommentsTestMixin, GenericDocumentViewTestCase):
def _create_test_comment(self):
self.test_comment = self.document.comments.create(
user=self.user, comment=TEST_COMMENT_TEXT
user=self._test_case_user, comment=TEST_COMMENT_TEXT
)
def test_document_comment_delete_view_no_permission(self):
@@ -54,7 +50,7 @@ class CommentsViewsTestCase(CommentsTestMixin, GenericDocumentViewTestCase):
def _request_document_comment_list_view(self):
return self.get(
viewname='comments:comments_for_document',
kwargs={'document_pk': self.document.pk}
kwargs={'document_id': self.document.pk}
)
def test_document_comment_list_view_no_permissions(self):