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
49 lines
1.6 KiB
Python
49 lines
1.6 KiB
Python
from __future__ import unicode_literals
|
|
|
|
from mayan.apps.common.tests.base import BaseTestCase
|
|
|
|
from ..permissions import permission_document_view
|
|
from ..search import document_search, document_page_search
|
|
|
|
from .mixins import DocumentTestMixin
|
|
|
|
|
|
class DocumentSearchTestMixin(object):
|
|
def _perform_document_page_search(self):
|
|
return document_page_search.search(
|
|
query_string={'q': self.test_document.label},
|
|
user=self._test_case_user
|
|
)
|
|
|
|
def _perform_document_search(self):
|
|
return document_search.search(
|
|
query_string={'q': self.test_document.label},
|
|
user=self._test_case_user
|
|
)
|
|
|
|
|
|
class DocumentSearchTestCase(
|
|
DocumentSearchTestMixin, DocumentTestMixin, BaseTestCase
|
|
):
|
|
def test_document_page_search_no_access(self):
|
|
queryset = self._perform_document_page_search()
|
|
self.assertFalse(self.test_document.pages.first() in queryset)
|
|
|
|
def test_document_page_search_with_access(self):
|
|
self.grant_access(
|
|
obj=self.test_document, permission=permission_document_view
|
|
)
|
|
queryset = self._perform_document_page_search()
|
|
self.assertTrue(self.test_document.pages.first() in queryset)
|
|
|
|
def test_document_search_no_access(self):
|
|
queryset = self._perform_document_search()
|
|
self.assertFalse(self.test_document in queryset)
|
|
|
|
def test_document_search_with_access(self):
|
|
self.grant_access(
|
|
obj=self.test_document, permission=permission_document_view
|
|
)
|
|
queryset = self._perform_document_search()
|
|
self.assertTrue(self.test_document in queryset)
|