Add support for new document page structure

Documents now have their own dedicated DocumentPage
submodel. The old DocumentPage is now called DocumentVersionPage.
This allows mappings between document pages and document version
pages, allowing renumbering, appending pages.
DocumentPages have a content_object to map them to any other
object. For now they only map to DocumentVersionPages.
New option added to the version upload form to append the
pages of the new version.
A new view was added to just append new pages with wraps the
new document version upload form and hides the append pages
checkbox set to True.
Add a new action, reset_pages to reset the pages of the
document to those of the latest version.

Missing: appending tests, checks for proper content_object in OCR and
document parsing.

Author: Roberto Rosario <roberto.rosario@mayan-edms.com>
Date:   Thu Oct 11 12:00:25 2019 -0400
This commit is contained in:
Roberto Rosario
2019-10-10 11:55:42 -04:00
parent 4a99a9df3e
commit 0699ad0556
87 changed files with 1973 additions and 707 deletions
+30 -7
View File
@@ -530,8 +530,7 @@ class DocumentPageAPIViewTestMixin(object):
page = self.test_document.pages.first()
return self.get(
viewname='rest_api:documentpage-image', kwargs={
'pk': page.document.pk, 'version_pk': page.document_version.pk,
'page_pk': page.pk
'pk': page.document.pk, 'page_pk': page.pk
}
)
@@ -552,6 +551,33 @@ class DocumentPageAPIViewTestCase(
self.assertEqual(response.status_code, status.HTTP_200_OK)
class DocumentVersionPageAPIViewTestMixin(object):
def _request_document_version_page_image(self):
page = self.test_document_version.pages.first()
return self.get(
viewname='rest_api:documentversionpage-image', kwargs={
'pk': page.document.pk, 'version_pk': page.document_version.pk,
'page_pk': page.pk
}
)
class DocumentVersionPageAPIViewTestCase(
DocumentVersionPageAPIViewTestMixin, DocumentTestMixin, BaseAPITestCase
):
def test_document_version_page_api_image_view_no_access(self):
response = self._request_document_version_page_image()
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
def test_document_version_page_api_image_view_with_access(self):
self.grant_access(
obj=self.test_document, permission=permission_document_view
)
response = self._request_document_version_page_image()
self.assertEqual(response.status_code, status.HTTP_200_OK)
class TrashedDocumentAPIViewTestMixin(object):
def _request_test_document_api_trash_view(self):
return self.delete(
@@ -575,13 +601,10 @@ class TrashedDocumentAPIViewTestMixin(object):
)
def _request_test_trashed_document_api_image_view(self):
latest_version = self.test_document.latest_version
return self.get(
viewname='rest_api:documentpage-image', kwargs={
'pk': latest_version.document.pk,
'version_pk': latest_version.pk,
'page_pk': latest_version.pages.first().pk
'pk': self.test_document.pk,
'page_pk': self.test_document.pages.first().pk
}
)