Convert half the widget to HTML widgets. Rename links and views to use the nomeclature _template_ and _instance_ to differenciate between index instances and index templates. Update URL parameters to use the "_id" form. Add more tests. Add model permission inheritance to the IndexTemplateNode, and IndexInstanceNode models. Remove the level and document count display from the instance node. Display instead the total items. Use a FilteredSelectionForm subclass to display the list of index templates to rebuild. Add missing icons. Add keyword arguments to links. Modernize tests to use the document test mixin. Update the permission requirements for the index template document type selection screen. The document type view permission is now required in addition to the index template edit permission. Use ExternalObjectMixin to reduce the code in all views. Signed-off-by: Roberto Rosario <Roberto.Rosario@mayan-edms.com>
32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
from __future__ import unicode_literals
|
|
|
|
from ..models import Index
|
|
|
|
from .literals import (
|
|
TEST_INDEX_LABEL, TEST_INDEX_TEMPLATE_DOCUMENT_LABEL_EXPRESSION
|
|
)
|
|
|
|
|
|
class IndexTemplateTestMixin(object):
|
|
def _create_index_template(self, add_document_type=False):
|
|
# Create empty index
|
|
self.test_index_template = Index.objects.create(label=TEST_INDEX_LABEL)
|
|
|
|
if add_document_type:
|
|
# Add our document type to the new index
|
|
self.test_index_template.document_types.add(self.test_document_type)
|
|
|
|
def _create_index_template_node(self, expression=None, rebuild=False):
|
|
self._create_index_template(add_document_type=True)
|
|
|
|
expression = expression or TEST_INDEX_TEMPLATE_DOCUMENT_LABEL_EXPRESSION
|
|
|
|
self.test_index_template_node = self.test_index_template.node_templates.create(
|
|
parent=self.test_index_template.template_root,
|
|
expression=expression, link_documents=True
|
|
)
|
|
|
|
# Rebuild indexes
|
|
if rebuild:
|
|
Index.objects.rebuild()
|