Update documents app
Rename the DeletedDocument proxy model to a TrashedDocument. Rename the deleted_document views to trashed_document. Rename the document and deleted_document URL parameters to trashed_document. Update URL parameters to the '_id' form. Add keyword arguments. Update use of .filter_by_access(). Enclose trashed document restore method in a transaction. Sort arguments. Update app for compliance with MERCs 5 and 6. Add document page view tests. Add favorite document view tests. Movernize tests. Replace use of urlencode with furl. Update views to use ExternalObjectMixin. Refactor the document and version download views. Rename the DocumentDocumentTypeEditView to DocumentChangeTypeView. Move the trashed document views to their own module. Signed-off-by: Roberto Rosario <Roberto.Rosario@mayan-edms.com>
This commit is contained in:
@@ -9,19 +9,15 @@ from .literals import TEST_MULTI_PAGE_TIFF
|
||||
|
||||
|
||||
class DocumentPageViewTestCase(GenericDocumentViewTestCase):
|
||||
def setUp(self):
|
||||
super(DocumentPageViewTestCase, self).setUp()
|
||||
self.login_user()
|
||||
|
||||
def _document_page_list_view(self):
|
||||
return self.get(
|
||||
viewname='documents:document_pages',
|
||||
kwargs={'document_pk': self.document.pk}
|
||||
kwargs={'document_id': self.document.pk}
|
||||
)
|
||||
|
||||
def test_document_page_list_view_no_permission(self):
|
||||
response = self._document_page_list_view()
|
||||
self.assertEqual(response.status_code, 403)
|
||||
self.assertEqual(response.status_code, 404)
|
||||
|
||||
def test_document_page_list_view_with_access(self):
|
||||
self.grant_access(
|
||||
@@ -32,18 +28,39 @@ class DocumentPageViewTestCase(GenericDocumentViewTestCase):
|
||||
response=response, text=self.document.label, status_code=200
|
||||
)
|
||||
|
||||
def _request_document_page_view(self, document_page):
|
||||
return self.get(
|
||||
viewname='documents:document_page_view', kwargs={
|
||||
'document_page_id': document_page.pk
|
||||
}
|
||||
)
|
||||
|
||||
def test_document_page_view_no_permissions(self):
|
||||
response = self._request_document_page_view(
|
||||
document_page=self.document.pages.first()
|
||||
)
|
||||
self.assertEqual(response.status_code, 404)
|
||||
|
||||
def test_document_page_view_with_access(self):
|
||||
self.grant_access(
|
||||
obj=self.document, permission=permission_document_view
|
||||
)
|
||||
response = self._request_document_page_view(
|
||||
document_page=self.document.pages.first()
|
||||
)
|
||||
self.assertContains(
|
||||
response=response, text=force_text(self.document.pages.first()),
|
||||
status_code=200
|
||||
)
|
||||
|
||||
|
||||
class DocumentPageNavigationViewTestCase(GenericDocumentViewTestCase):
|
||||
test_document_filename = TEST_MULTI_PAGE_TIFF
|
||||
|
||||
def setUp(self):
|
||||
super(DocumentPageNavigationViewTestCase, self).setUp()
|
||||
self.login_user()
|
||||
|
||||
def _request_document_page_navigation_next_view(self):
|
||||
return self.get(
|
||||
viewname='documents:document_page_navigation_next',
|
||||
kwargs={'document_page_pk': self.document.pages.first().pk},
|
||||
kwargs={'document_page_id': self.document.pages.first().pk},
|
||||
follow=True
|
||||
)
|
||||
|
||||
@@ -51,7 +68,6 @@ class DocumentPageNavigationViewTestCase(GenericDocumentViewTestCase):
|
||||
self.grant_access(
|
||||
obj=self.document, permission=permission_document_view
|
||||
)
|
||||
|
||||
response = self._request_document_page_navigation_next_view()
|
||||
|
||||
self.assertContains(
|
||||
@@ -62,7 +78,7 @@ class DocumentPageNavigationViewTestCase(GenericDocumentViewTestCase):
|
||||
def _request_document_page_navigation_last_view(self):
|
||||
return self.get(
|
||||
viewname='documents:document_page_navigation_last',
|
||||
kwargs={'document_page_pk': self.document.pages.first().pk},
|
||||
kwargs={'document_page_id': self.document.pages.first().pk},
|
||||
follow=True
|
||||
)
|
||||
|
||||
@@ -70,7 +86,6 @@ class DocumentPageNavigationViewTestCase(GenericDocumentViewTestCase):
|
||||
self.grant_access(
|
||||
obj=self.document, permission=permission_document_view
|
||||
)
|
||||
|
||||
response = self._request_document_page_navigation_last_view()
|
||||
|
||||
self.assertContains(
|
||||
@@ -81,7 +96,7 @@ class DocumentPageNavigationViewTestCase(GenericDocumentViewTestCase):
|
||||
def _request_document_page_navigation_previous_view(self):
|
||||
return self.get(
|
||||
viewname='documents:document_page_navigation_previous',
|
||||
kwargs={'document_page_pk': self.document.pages.last().pk},
|
||||
kwargs={'document_page_id': self.document.pages.last().pk},
|
||||
follow=True
|
||||
)
|
||||
|
||||
@@ -89,7 +104,6 @@ class DocumentPageNavigationViewTestCase(GenericDocumentViewTestCase):
|
||||
self.grant_access(
|
||||
obj=self.document, permission=permission_document_view
|
||||
)
|
||||
|
||||
response = self._request_document_page_navigation_previous_view()
|
||||
|
||||
self.assertContains(
|
||||
@@ -100,7 +114,7 @@ class DocumentPageNavigationViewTestCase(GenericDocumentViewTestCase):
|
||||
def _request_document_page_navigation_first_view(self):
|
||||
return self.get(
|
||||
viewname='documents:document_page_navigation_first',
|
||||
kwargs={'document_page_pk': self.document.pages.last().pk},
|
||||
kwargs={'document_page_id': self.document.pages.last().pk},
|
||||
follow=True
|
||||
)
|
||||
|
||||
@@ -108,7 +122,6 @@ class DocumentPageNavigationViewTestCase(GenericDocumentViewTestCase):
|
||||
self.grant_access(
|
||||
obj=self.document, permission=permission_document_view
|
||||
)
|
||||
|
||||
response = self._request_document_page_navigation_first_view()
|
||||
|
||||
self.assertContains(
|
||||
|
||||
Reference in New Issue
Block a user