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

View File

@@ -8,7 +8,7 @@ from django.utils.translation import ugettext_lazy as _, ugettext
from mayan.apps.common.widgets import TextAreaDiv
from .models import DocumentPageContent
from .models import DocumentVersionPageContent
class DocumentContentForm(forms.Form):
@@ -26,10 +26,10 @@ class DocumentContentForm(forms.Form):
except AttributeError:
document_pages = []
for page in document_pages:
for document_page in document_pages:
try:
page_content = page.content.content
except DocumentPageContent.DoesNotExist:
page_content = document_page.content_object.content.content
except DocumentVersionPageContent.DoesNotExist:
pass
else:
content.append(conditional_escape(force_text(page_content)))
@@ -37,7 +37,7 @@ class DocumentContentForm(forms.Form):
'\n\n\n<hr/><div class="document-page-content-divider">- %s -</div><hr/>\n\n\n' % (
ugettext(
'Page %(page_number)d'
) % {'page_number': page.page_number}
) % {'page_number': document_page.page_number}
)
)
@@ -72,8 +72,8 @@ class DocumentPageContentForm(forms.Form):
self.fields['contents'].initial = ''
try:
page_content = document_page.content.content
except DocumentPageContent.DoesNotExist:
page_content = document_page.content_object.content.content
except DocumentVersionPageContent.DoesNotExist:
pass
else:
content = conditional_escape(force_text(page_content))