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
58 lines
1.8 KiB
Python
58 lines
1.8 KiB
Python
from __future__ import unicode_literals
|
|
|
|
from actstream.models import Action
|
|
|
|
from mayan.apps.documents.tests.literals import TEST_PDF_DOCUMENT_FILENAME
|
|
from mayan.apps.documents.tests.test_models import GenericDocumentTestCase
|
|
|
|
from ..events import (
|
|
event_parsing_document_content_deleted,
|
|
event_parsing_document_version_submit,
|
|
event_parsing_document_version_finish
|
|
)
|
|
from ..models import DocumentVersionPageContent
|
|
|
|
|
|
class DocumentParsingEventsTestCase(GenericDocumentTestCase):
|
|
# Ensure we use a PDF file
|
|
test_document_filename = TEST_PDF_DOCUMENT_FILENAME
|
|
|
|
def test_document_content_deleted_event(self):
|
|
Action.objects.all().delete()
|
|
DocumentVersionPageContent.objects.delete_content_for(
|
|
document=self.test_document
|
|
)
|
|
|
|
# Get the oldest action
|
|
action = Action.objects.order_by('-timestamp').last()
|
|
|
|
self.assertEqual(
|
|
action.target, self.test_document
|
|
)
|
|
self.assertEqual(
|
|
action.verb, event_parsing_document_content_deleted.id
|
|
)
|
|
|
|
def test_document_version_submit_event(self):
|
|
Action.objects.all().delete()
|
|
self.test_document.submit_for_parsing()
|
|
|
|
self.assertEqual(
|
|
Action.objects.last().target, self.test_document.latest_version
|
|
)
|
|
self.assertEqual(
|
|
Action.objects.last().verb,
|
|
event_parsing_document_version_submit.id
|
|
)
|
|
|
|
def test_document_version_finish_event(self):
|
|
Action.objects.all().delete()
|
|
self.test_document.submit_for_parsing()
|
|
self.assertEqual(
|
|
Action.objects.first().target, self.test_document.latest_version
|
|
)
|
|
self.assertEqual(
|
|
Action.objects.first().verb,
|
|
event_parsing_document_version_finish.id
|
|
)
|