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:
@@ -12,10 +12,12 @@ from mayan.apps.common.generics import (
|
||||
)
|
||||
from mayan.apps.common.mixins import ExternalObjectMixin
|
||||
from mayan.apps.documents.forms import DocumentTypeFilteredSelectForm
|
||||
from mayan.apps.documents.models import Document, DocumentPage, DocumentType
|
||||
from mayan.apps.documents.models import (
|
||||
Document, DocumentPage, DocumentType, DocumentVersionPage
|
||||
)
|
||||
|
||||
from .forms import DocumentContentForm, DocumentPageContentForm
|
||||
from .models import DocumentPageContent, DocumentVersionParseError
|
||||
from .models import DocumentVersionPageContent, DocumentVersionParseError
|
||||
from .permissions import (
|
||||
permission_content_view, permission_document_type_parsing_setup,
|
||||
permission_parse_document
|
||||
@@ -46,7 +48,7 @@ class DocumentContentDeleteView(MultipleObjectConfirmActionView):
|
||||
return result
|
||||
|
||||
def object_action(self, form, instance):
|
||||
DocumentPageContent.objects.delete_content_for(
|
||||
DocumentVersionPageContent.objects.delete_content_for(
|
||||
document=instance, user=self.request.user
|
||||
)
|
||||
|
||||
@@ -107,6 +109,30 @@ class DocumentPageContentView(SingleObjectDetailView):
|
||||
}
|
||||
|
||||
|
||||
class DocumentVersionPageContentView(SingleObjectDetailView):
|
||||
form_class = DocumentPageContentForm
|
||||
model = DocumentVersionPage
|
||||
object_permission = permission_content_view
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
result = super(DocumentPageContentView, self).dispatch(
|
||||
request, *args, **kwargs
|
||||
)
|
||||
self.get_object().document.add_as_recent_document_for_user(
|
||||
request.user
|
||||
)
|
||||
return result
|
||||
|
||||
def get_extra_context(self):
|
||||
return {
|
||||
'hide_labels': True,
|
||||
'object': self.get_object(),
|
||||
'title': _(
|
||||
'Content for document version page: %s'
|
||||
) % self.get_object(),
|
||||
}
|
||||
|
||||
|
||||
class DocumentParsingErrorsListView(SingleObjectListView):
|
||||
view_permission = permission_content_view
|
||||
|
||||
|
||||
Reference in New Issue
Block a user