diff --git a/mayan/apps/acls/apps.py b/mayan/apps/acls/apps.py index f634672c91..49b937b5ef 100644 --- a/mayan/apps/acls/apps.py +++ b/mayan/apps/acls/apps.py @@ -30,16 +30,11 @@ class ACLsApp(apps.AppConfig): verbose_name = _('ACLs') def ready(self): - menu_sidebar.bind_links(links=[link_acl_holder_new], sources=[AccessObject]) - - #register_links(AccessObjectClass, [acl_class_acl_list, acl_class_new_holder_for]) - #register_links(AccessHolder, [acl_detail]) - #register_links(ClassAccessHolder, [acl_class_acl_detail]) - #register_links(['acls:acl_detail'], [acl_grant, acl_revoke], menu_name='multi_item_links') - #register_links(['acls:acl_class_acl_detail'], [acl_class_grant, acl_class_revoke], menu_name='multi_item_links') - menu_setup.bind_links(links=[link_acl_setup_valid_classes]) - post_migrate.connect(create_creator_user, dispatch_uid='create_creator_user') - + menu_multi_item.bind_links(links=[link_acl_class_grant, link_acl_class_revoke], sources=['acls:acl_class_acl_detail']) + menu_multi_item.bind_links(links=[link_acl_grant, link_acl_revoke], sources=['acls:acl_detail']) + menu_object.bind_links(links=[link_acl_class_acl_detail], sources=[ClassAccessHolder]) + menu_object.bind_links(links=[link_acl_class_acl_list, link_acl_class_new_holder_for], sources=[AccessObjectClass]) + menu_object.bind_links(links=[link_acl_detail], sources=[AccessHolder]) menu_secondary.bind_links( links=[link_acl_class_list], sources=[ @@ -49,3 +44,7 @@ class ACLsApp(apps.AppConfig): 'acls:acl_class_multiple_revoke' ], ) + menu_setup.bind_links(links=[link_acl_setup_valid_classes]) + menu_sidebar.bind_links(links=[link_acl_holder_new], sources=[AccessObject]) + + post_migrate.connect(create_creator_user, dispatch_uid='create_creator_user') diff --git a/mayan/apps/django_gpg/apps.py b/mayan/apps/django_gpg/apps.py index f9d726f270..05ca9d6c3a 100644 --- a/mayan/apps/django_gpg/apps.py +++ b/mayan/apps/django_gpg/apps.py @@ -5,11 +5,12 @@ from django.utils.translation import ugettext_lazy as _ from hkp import Key as KeyServerKey -from common import menu_setup +from common import menu_object, menu_setup, menu_sidebar from .api import Key from .links import ( - key_delete, key_query, key_receive, link_key_setup, public_keys + link_key_delete, link_key_query, link_key_receive, link_key_setup, + link_public_keys ) @@ -18,8 +19,7 @@ class DjangoGPGApp(apps.AppConfig): verbose_name = _('Django GPG') def ready(self): - # TODO: convert - #register_links(['django_gpg:key_delete', 'django_gpg:key_public_list', 'django_gpg:key_query'], [public_keys, key_query], menu_name='sidebar') - #register_links(Key, [key_delete]) - #register_links(KeyServerKey, [key_receive]) + menu_object.bind_links(links=[link_key_delete], sources=[Key]) + menu_object.bind_links(links=[link_key_receive], sources=[KeyServerKey]) menu_setup.bind_links(links=[link_key_setup]) + menu_sidebar.bind_links(links=[link_public_keys, link_key_query], sources=['django_gpg:key_delete', 'django_gpg:key_public_list', 'django_gpg:key_query']) diff --git a/mayan/apps/django_gpg/links.py b/mayan/apps/django_gpg/links.py index 0b09f86549..25ab9cecd5 100644 --- a/mayan/apps/django_gpg/links.py +++ b/mayan/apps/django_gpg/links.py @@ -9,9 +9,9 @@ from .permissions import ( PERMISSION_KEYSERVER_QUERY ) -private_keys = {'text': _('Private keys'), 'view': 'django_gpg:key_private_list', 'args': 'object.pk', 'icon': 'fa fa-key', 'permissions': [PERMISSION_KEY_VIEW]} -public_keys = {'text': _('Public keys'), 'view': 'django_gpg:key_public_list', 'args': 'object.pk', 'icon': 'fa fa-key', 'permissions': [PERMISSION_KEY_VIEW]} -key_delete = {'text': _('Delete'), 'view': 'django_gpg:key_delete', 'args': ['object.fingerprint', 'object.type'], 'famfam': 'key_delete', 'permissions': [PERMISSION_KEY_DELETE]} -key_query = {'text': _('Query keyservers'), 'view': 'django_gpg:key_query', 'famfam': 'zoom', 'permissions': [PERMISSION_KEYSERVER_QUERY]} -key_receive = {'text': _('Import'), 'view': 'django_gpg:key_receive', 'args': 'object.keyid', 'famfam': 'key_add', 'keep_query': True, 'permissions': [PERMISSION_KEY_RECEIVE]} +link_private_keys = Link(icon='fa fa-key', permissions=[PERMISSION_KEY_VIEW], text=_('Private keys'), view='django_gpg:key_private_list', args='object.pk') +link_public_keys = Link(icon='fa fa-key', permissions=[PERMISSION_KEY_VIEW], text=_('Public keys'), view='django_gpg:key_public_list', args='object.pk') +link_key_delete = Link(permissions=[PERMISSION_KEY_DELETE], text=_('Delete'), view='django_gpg:key_delete', args=['object.fingerprint', 'object.type']) +link_key_query = Link(text=_('Query keyservers'), view='django_gpg:key_query', permissions=[PERMISSION_KEYSERVER_QUERY]) +link_key_receive = Link(keep_query=True, permissions=[PERMISSION_KEY_RECEIVE], text=_('Import'), view='django_gpg:key_receive', args='object.keyid') link_key_setup = Link(icon='fa fa-key', permissions=[PERMISSION_KEY_VIEW], text=_('Key management'), view='django_gpg:key_public_list', args='object.pk') diff --git a/mayan/apps/document_acls/apps.py b/mayan/apps/document_acls/apps.py index 065215278f..5c250aa5ca 100644 --- a/mayan/apps/document_acls/apps.py +++ b/mayan/apps/document_acls/apps.py @@ -5,9 +5,10 @@ from django.utils.translation import ugettext_lazy as _ from acls.api import class_permissions from acls.permissions import ACLS_VIEW_ACL, ACLS_EDIT_ACL +from common import menu_facet from documents.models import Document -from .links import acl_list +from .links import link_acl_list class DocumentACLsApp(apps.AppConfig): @@ -15,10 +16,9 @@ class DocumentACLsApp(apps.AppConfig): verbose_name = _('Document ACLs') def ready(self): - #TODO: convert - #register_links(Document, [acl_list], menu_name='form_header') - class_permissions(Document, [ ACLS_VIEW_ACL, ACLS_EDIT_ACL ]) + + menu_facet.bind_links(links=[link_acl_list], sources=[Document]) diff --git a/mayan/apps/document_acls/links.py b/mayan/apps/document_acls/links.py index 31e8f3f5be..4630c579f4 100644 --- a/mayan/apps/document_acls/links.py +++ b/mayan/apps/document_acls/links.py @@ -3,5 +3,6 @@ from __future__ import unicode_literals from django.utils.translation import ugettext_lazy as _ from acls.permissions import ACLS_VIEW_ACL +from navigation import Link -acl_list = {'text': _('ACLs'), 'view': 'document_acls:document_acl_list', 'args': 'object.pk', 'famfam': 'lock', 'permissions': [ACLS_VIEW_ACL]} +link_acl_list = Link(permissions=[ACLS_VIEW_ACL], text=_('ACLs'), view='document_acls:document_acl_list', args='object.pk') diff --git a/mayan/apps/document_comments/apps.py b/mayan/apps/document_comments/apps.py index ba5063f35d..6bef8815ed 100644 --- a/mayan/apps/document_comments/apps.py +++ b/mayan/apps/document_comments/apps.py @@ -6,12 +6,15 @@ from django.contrib.contenttypes import generic from django.utils.translation import ugettext_lazy as _ from acls.api import class_permissions +from common import menu_facet, menu_object, menu_sidebar from common.classes import ModelAttribute from common.utils import encapsulate from documents.models import Document from navigation.api import register_model_list_columns -from .links import comment_add, comment_delete, comments_for_document +from .links import ( + link_comment_add, link_comment_delete, link_comments_for_document +) from .permissions import ( PERMISSION_COMMENT_CREATE, PERMISSION_COMMENT_DELETE, PERMISSION_COMMENT_VIEW @@ -32,10 +35,13 @@ class DocumentCommentsApp(apps.AppConfig): ) ) + ModelAttribute(Document, label=_('Comments'), name='comments', type_name='related') + class_permissions(Document, [ PERMISSION_COMMENT_CREATE, PERMISSION_COMMENT_DELETE, - PERMISSION_COMMENT_VIEW]) + PERMISSION_COMMENT_VIEW] + ) register_model_list_columns(Comment, [ { @@ -52,9 +58,6 @@ class DocumentCommentsApp(apps.AppConfig): } ]) - # TODO: convert - #register_links(['comments:comments_for_document', 'comments:comment_add', 'comments:comment_delete', 'comments:comment_multiple_delete'], [comment_add], menu_name='sidebar') - #register_links(Comment, [comment_delete]) - #register_links(Document, [comments_for_document], menu_name='form_header') - - ModelAttribute(Document, label=_('Comments'), name='comments', type_name='related') + menu_sidebar.bind_links(links=[link_comment_add], sources=['comments:comments_for_document', 'comments:comment_add', 'comments:comment_delete', 'comments:comment_multiple_delete']) + menu_object.bind_links(links=[link_comment_delete], sources=[Comment]) + menu_facet.bind_links(links=[link_comments_for_document], sources=[Document]) diff --git a/mayan/apps/document_comments/links.py b/mayan/apps/document_comments/links.py index 1034b526eb..51e7c13fbb 100644 --- a/mayan/apps/document_comments/links.py +++ b/mayan/apps/document_comments/links.py @@ -2,12 +2,14 @@ from __future__ import unicode_literals, absolute_import from django.utils.translation import ugettext_lazy as _ +from navigation import Link + from .permissions import ( PERMISSION_COMMENT_CREATE, PERMISSION_COMMENT_DELETE, PERMISSION_COMMENT_VIEW ) -comment_delete = {'text': _('Delete'), 'view': 'comments:comment_delete', 'args': 'object.pk', 'famfam': 'comment_delete', 'permissions': [PERMISSION_COMMENT_DELETE]} -comment_multiple_delete = {'text': _('Delete'), 'view': 'comments:comment_multiple_delete', 'args': 'object.pk', 'famfam': 'comments_delete', 'permissions': [PERMISSION_COMMENT_DELETE]} -comment_add = {'text': _('Add comment'), 'view': 'comments:comment_add', 'args': 'object.pk', 'famfam': 'comment_add', 'permissions': [PERMISSION_COMMENT_CREATE]} -comments_for_document = {'text': _('Comments'), 'view': 'comments:comments_for_document', 'args': 'object.pk', 'famfam': 'comments', 'permissions': [PERMISSION_COMMENT_VIEW]} +link_comment_add = Link(permissions=[PERMISSION_COMMENT_CREATE], text=_('Add comment'), view='comments:comment_add', args='object.pk') +link_comment_delete = Link(permissions=[PERMISSION_COMMENT_DELETE], text=_('Delete'), view='comments:comment_delete', args='object.pk') +link_comment_multiple_delete = Link(permissions=[PERMISSION_COMMENT_DELETE], text=_('Delete'), view='comments:comment_multiple_delete', args='object.pk') +link_comments_for_document = Link(permissions=[PERMISSION_COMMENT_VIEW], text=_('Comments'), view='comments:comments_for_document', args='object.pk') diff --git a/mayan/apps/document_indexing/apps.py b/mayan/apps/document_indexing/apps.py index 962eae2cc2..cec24e7a59 100644 --- a/mayan/apps/document_indexing/apps.py +++ b/mayan/apps/document_indexing/apps.py @@ -4,7 +4,9 @@ from django import apps from django.db.models.signals import post_save, post_delete from django.utils.translation import ugettext_lazy as _ -from common import menu_main, menu_setup +from common import ( + menu_facet, menu_main, menu_object, menu_secondary, menu_setup +) from documents.models import Document from main.api import register_maintenance_links from metadata.models import DocumentMetadata @@ -41,19 +43,16 @@ class DocumentIndexingApp(apps.AppConfig): def ready(self): APIEndPoint('indexes', app_name='document_indexing') - # TODO: convert - #register_links(Document, [document_index_list], menu_name='form_header') - #register_links([Index, 'indexing:index_setup_list', 'indexing:index_setup_create'], [index_setup_list, index_setup_create], menu_name='secondary_menu') - #register_links(Index, [index_setup_edit, index_setup_view, index_setup_document_types, index_setup_delete]) - #register_links(IndexInstanceNode, [index_parent]) - #register_links(IndexTemplateNode, [template_node_create, template_node_edit, template_node_delete]) - + menu_facet.bind_links(links=[link_document_index_list], sources=[Document]) + menu_object.bind_links(links=[link_index_parent], sources=[IndexInstanceNode]) + menu_object.bind_links(links=[link_index_setup_edit, link_index_setup_view, link_index_setup_document_types, link_index_setup_delete], sources=[Index]) + menu_object.bind_links(links=[link_template_node_create, link_template_node_edit, link_template_node_delete], sources=[IndexTemplateNode]) + menu_main.bind_links(links=[link_index_main_menu]) + menu_secondary.bind_links(links=[link_index_setup_list, link_index_setup_create], sources=[Index, 'indexing:index_setup_list', 'indexing:index_setup_create']) menu_setup.bind_links(links=[link_index_setup]) - menu_main.bind_links(links=[link_index_main_menu]) - - post_delete.connect(document_index_delete, dispatch_uid='document_index_delete', sender=Document) post_save.connect(document_metadata_index_update, dispatch_uid='document_metadata_index_update', sender=DocumentMetadata) + post_delete.connect(document_index_delete, dispatch_uid='document_index_delete', sender=Document) post_delete.connect(document_metadata_index_post_delete, dispatch_uid='document_metadata_index_post_delete', sender=DocumentMetadata) register_maintenance_links([link_rebuild_index_instances], namespace='document_indexing', title=_('Indexes')) diff --git a/mayan/apps/document_states/apps.py b/mayan/apps/document_states/apps.py index 82a700448d..5f742f133d 100644 --- a/mayan/apps/document_states/apps.py +++ b/mayan/apps/document_states/apps.py @@ -4,7 +4,9 @@ from django import apps from django.db.models.signals import post_save from django.utils.translation import ugettext_lazy as _ -from common import menu_setup +from common import ( + menu_facet, menu_object, menu_secondary, menu_setup, menu_sidebar +) from common.utils import encapsulate from documents.models import Document from navigation.api import register_model_list_columns @@ -35,9 +37,14 @@ class DocumentStatesApp(apps.AppConfig): verbose_name = _('Document states') def ready(self): - post_save.connect(launch_workflow, dispatch_uid='launch_workflow', sender=Document) - + menu_facet.bind_links(links=[link_document_workflow_instance_list], sources=[Document]) + menu_object.bind_links(links=[link_setup_workflow_states, link_setup_workflow_transitions, link_setup_workflow_document_types, link_setup_workflow_edit, link_setup_workflow_delete], sources=[Workflow]) + menu_object.bind_links(links=[link_setup_workflow_state_edit, link_setup_workflow_state_delete], sources=[WorkflowState]) + menu_object.bind_links(links=[link_setup_workflow_transition_edit, link_setup_workflow_transition_delete], sources=[WorkflowTransition]) + menu_object.bind_links(links=[link_workflow_instance_detail, link_workflow_instance_transition], sources=[WorkflowInstance]) + menu_secondary.bind_links(links=[link_setup_workflow_list, link_setup_workflow_create], sources=[Workflow, 'document_states:setup_workflow_create', 'document_states:setup_workflow_list']) menu_setup.bind_links(links=[link_setup_workflow_list]) + menu_sidebar.bind_links(links=[link_setup_workflow_state_create, link_setup_workflow_transition_create], sources=[Workflow]) register_model_list_columns(Workflow, [ { @@ -46,13 +53,6 @@ class DocumentStatesApp(apps.AppConfig): }, ]) - register_model_list_columns(WorkflowState, [ - { - 'name': _('Is initial state?'), - 'attribute': 'initial' - }, - ]) - register_model_list_columns(WorkflowInstance, [ { 'name': _('Current state'), @@ -72,17 +72,6 @@ class DocumentStatesApp(apps.AppConfig): }, ]) - register_model_list_columns(WorkflowTransition, [ - { - 'name': _('Origin state'), - 'attribute': 'origin_state' - }, - { - 'name': _('Destination state'), - 'attribute': 'destination_state' - }, - ]) - register_model_list_columns(WorkflowInstanceLogEntry, [ { 'name': _('Date and time'), @@ -102,11 +91,22 @@ class DocumentStatesApp(apps.AppConfig): }, ]) - # TODO: convert - #register_links([Document], [link_document_workflow_instance_list], menu_name='form_header') - #register_links([WorkflowInstance], [link_workflow_instance_detail, link_workflow_instance_transition]) - #register_links([Workflow, 'document_states:setup_workflow_create', 'document_states:setup_workflow_list'], [link_setup_workflow_list, link_setup_workflow_create], menu_name='secondary_menu') - #register_links([Workflow], [link_setup_workflow_states, link_setup_workflow_transitions, link_setup_workflow_document_types, link_setup_workflow_edit, link_setup_workflow_delete]) - ##register_links([Workflow], [link_setup_workflow_state_create, link_setup_workflow_transition_create], menu_name='sidebar') - #register_links([WorkflowState], [link_setup_workflow_state_edit, link_setup_workflow_state_delete]) - #register_links([WorkflowTransition], [link_setup_workflow_transition_edit, link_setup_workflow_transition_delete]) + register_model_list_columns(WorkflowState, [ + { + 'name': _('Is initial state?'), + 'attribute': 'initial' + }, + ]) + + register_model_list_columns(WorkflowTransition, [ + { + 'name': _('Origin state'), + 'attribute': 'origin_state' + }, + { + 'name': _('Destination state'), + 'attribute': 'destination_state' + }, + ]) + + post_save.connect(launch_workflow, dispatch_uid='launch_workflow', sender=Document) diff --git a/mayan/apps/document_states/links.py b/mayan/apps/document_states/links.py index ee4ab994d0..34ec1f3494 100644 --- a/mayan/apps/document_states/links.py +++ b/mayan/apps/document_states/links.py @@ -4,23 +4,19 @@ from django.utils.translation import ugettext_lazy as _ from navigation import Link +link_document_workflow_instance_list = Link(text=_('Workflows'), view='document_states:document_workflow_instance_list', args='object.pk') +link_setup_workflow_create = Link(text=_('Create'), view='document_states:setup_workflow_create') +link_setup_workflow_delete = Link(text=_('Delete'), view='document_states:setup_workflow_delete', args='object.pk') +link_setup_workflow_document_types = Link(text=_('Document types'), view='document_states:setup_workflow_document_types', args='object.pk') +link_setup_workflow_edit = Link(text=_('Edit'), view='document_states:setup_workflow_edit', args='object.pk') link_setup_workflow_list = Link(icon='fa fa-table', text=_('Workflows'), view='document_states:setup_workflow_list') -link_setup_workflow_create = {'text': _('Create'), 'view': 'document_states:setup_workflow_create', 'famfam': 'table_add'} -link_setup_workflow_delete = {'text': _('Delete'), 'view': 'document_states:setup_workflow_delete', 'args': 'object.pk', 'famfam': 'table_delete'} -link_setup_workflow_edit = {'text': _('Edit'), 'view': 'document_states:setup_workflow_edit', 'args': 'object.pk', 'famfam': 'table_edit'} - -link_setup_workflow_states = {'text': _('States'), 'view': 'document_states:setup_workflow_states', 'args': 'object.pk', 'famfam': 'style'} -link_setup_workflow_state_create = {'text': _('Create state'), 'view': 'document_states:setup_workflow_state_create', 'args': 'object.pk', 'famfam': 'style_add'} -link_setup_workflow_state_delete = {'text': _('Delete'), 'view': 'document_states:setup_workflow_state_delete', 'args': 'object.pk', 'famfam': 'delete'} -link_setup_workflow_state_edit = {'text': _('Edit'), 'view': 'document_states:setup_workflow_state_edit', 'args': 'object.pk', 'famfam': 'pencil'} - -link_setup_workflow_transitions = {'text': _('Transitions'), 'view': 'document_states:setup_workflow_transitions', 'args': 'object.pk', 'famfam': 'lightning'} -link_setup_workflow_transition_create = {'text': _('Create transition'), 'view': 'document_states:setup_workflow_transition_create', 'args': 'object.pk', 'famfam': 'lightning_add'} -link_setup_workflow_transition_delete = {'text': _('Delete'), 'view': 'document_states:setup_workflow_transition_delete', 'args': 'object.pk', 'famfam': 'delete'} -link_setup_workflow_transition_edit = {'text': _('Edit'), 'view': 'document_states:setup_workflow_transition_edit', 'args': 'object.pk', 'famfam': 'pencil'} - -link_setup_workflow_document_types = {'text': _('Document types'), 'view': 'document_states:setup_workflow_document_types', 'args': 'object.pk', 'famfam': 'layout'} - -link_document_workflow_instance_list = {'text': _('Workflows'), 'view': 'document_states:document_workflow_instance_list', 'args': 'object.pk', 'famfam': 'table'} -link_workflow_instance_detail = {'text': _('Detail'), 'view': 'document_states:workflow_instance_detail', 'args': 'workflow_instance.pk', 'famfam': 'table'} -link_workflow_instance_transition = {'text': _('Transition'), 'view': 'document_states:workflow_instance_transition', 'args': 'workflow_instance.pk', 'famfam': 'table_lightning'} +link_setup_workflow_state_create = Link(text=_('Create state'), view='document_states:setup_workflow_state_create', args='object.pk') +link_setup_workflow_state_delete = Link(text=_('Delete'), view='document_states:setup_workflow_state_delete', args='object.pk') +link_setup_workflow_state_edit = Link(text=_('Edit'), view='document_states:setup_workflow_state_edit', args='object.pk') +link_setup_workflow_states = Link(text=_('States'), view='document_states:setup_workflow_states', args='object.pk') +link_setup_workflow_transition_create = Link(text=_('Create transition'), view='document_states:setup_workflow_transition_create', args='object.pk') +link_setup_workflow_transition_delete = Link(text=_('Delete'), view='document_states:setup_workflow_transition_delete', args='object.pk') +link_setup_workflow_transition_edit = Link(text=_('Edit'), view='document_states:setup_workflow_transition_edit', args='object.pk') +link_setup_workflow_transitions = Link(text=_('Transitions'), view='document_states:setup_workflow_transitions', args='object.pk') +link_workflow_instance_detail = Link(text=_('Detail'), view='document_states:workflow_instance_detail', args='workflow_instance.pk') +link_workflow_instance_transition = Link(text=_('Transition'), view='document_states:workflow_instance_transition', args='workflow_instance.pk') diff --git a/mayan/apps/documents/apps.py b/mayan/apps/documents/apps.py index b77e5a5086..de8c44311d 100644 --- a/mayan/apps/documents/apps.py +++ b/mayan/apps/documents/apps.py @@ -71,58 +71,16 @@ class DocumentsApp(apps.AppConfig): verbose_name = _('Documents') def ready(self): - APIEndPoint('documents') - DocumentPage.add_to_class('get_transformation_list', lambda document_page: DocumentPageTransformation.objects.get_for_document_page_as_list(document_page)) - - MissingItem(label=_('Create a document type'), description=_('Every uploaded document must be assigned a document type, it is the basic way Mayan EDMS categorizes documents.'), condition=lambda: not DocumentType.objects.exists(), view='documents:document_type_list') - ModelAttribute(Document, label=_('Label'), name='label', type_name='field') - - menu_front_page.bind_links(links=[link_document_list_recent, link_document_list]) - - # Document type links - menu_object.bind_links(links=[link_document_type_edit, link_document_type_filename_list, link_document_type_delete], sources=[DocumentType]) - menu_secondary.bind_links(links=[link_document_type_list, link_document_type_create], sources=[DocumentType, 'documents:document_type_create', 'documents:document_type_list']) - - menu_object.bind_links(links=[link_document_type_filename_edit, link_document_type_filename_delete], sources=[DocumentTypeFilename]) - menu_sidebar.bind_links(links=[link_document_type_filename_create], sources=[DocumentTypeFilename, 'documents:document_type_filename_list', 'documents:document_type_filename_create']) - - # Register document facet links - menu_facet.bind_links(links=[link_document_preview], sources=[Document], position=0) - menu_facet.bind_links(links=[link_document_content], sources=[Document], position=1) - menu_facet.bind_links(links=[link_document_properties], sources=[Document], position=2) - menu_facet.bind_links(links=[link_document_events_view, link_document_version_list], sources=[Document], position=2) - - # Document actions - menu_object.bind_links(links=[link_document_edit, link_document_document_type_edit, link_document_print, link_document_delete, link_document_download, link_document_clear_transformations, link_document_update_page_count], sources=[Document]) - - menu_multi_item.bind_links(links=[link_document_multiple_clear_transformations, link_document_multiple_delete, link_document_multiple_download, link_document_multiple_update_page_count, link_document_multiple_document_type_edit], sources=[Document]) - menu_object.bind_links(links=[link_document_version_revert, link_document_version_download], sources=[DocumentVersion]) - - menu_object.bind_links(links=[link_document_page_transformation_list, link_document_page_view, link_document_page_text, link_document_page_edit], sources=[DocumentPage]) - menu_sidebar.bind_links(links=[link_document_page_navigation_first, link_document_page_navigation_previous, link_document_page_navigation_next, link_document_page_navigation_last], sources=[DocumentPage]) - - menu_facet.bind_links(links=[link_document_page_rotate_left, link_document_page_rotate_right, link_document_page_zoom_in, link_document_page_zoom_out, link_document_page_view_reset], sources=['documents:document_page_view']) - - #register_links(DocumentPageTransformation, [document_page_transformation_edit, document_page_transformation_delete]) - #register_links('documents:document_page_transformation_list', [document_page_transformation_create], menu_name='sidebar') - #register_links('documents:document_page_transformation_create', [document_page_transformation_create], menu_name='sidebar') - #register_links(['documents:document_page_transformation_edit', 'documents:document_page_transformation_delete'], [document_page_transformation_create], menu_name='sidebar') - - register_maintenance_links([link_clear_image_cache], namespace='documents', title=_('Documents')) - register_model_list_columns(Document, [ - { - 'name': _('Thumbnail'), 'attribute': - encapsulate(lambda x: document_thumbnail(x, gallery_name='documents:document_list', title=getattr(x, 'filename', None), size=THUMBNAIL_SIZE)) - }, - { - 'name': _('Type'), 'attribute': 'document_type' - } - ]) - if (not validate_path(document_settings.CACHE_PATH)) or (not document_settings.CACHE_PATH): setattr(document_settings, 'CACHE_PATH', tempfile.mkdtemp()) - menu_setup.bind_links(links=[link_document_type_setup]) + APIEndPoint('documents') + + DocumentPage.add_to_class('get_transformation_list', lambda document_page: DocumentPageTransformation.objects.get_for_document_page_as_list(document_page)) + + MissingItem(label=_('Create a document type'), description=_('Every uploaded document must be assigned a document type, it is the basic way Mayan EDMS categorizes documents.'), condition=lambda: not DocumentType.objects.exists(), view='documents:document_type_list') + + ModelAttribute(Document, label=_('Label'), name='label', type_name='field') class_permissions(Document, [ PERMISSION_DOCUMENT_DELETE, PERMISSION_DOCUMENT_DOWNLOAD, @@ -145,8 +103,49 @@ class DocumentsApp(apps.AppConfig): document_search.add_model_field('description', label=_('Description')) document_search.add_model_field('tags__label', label=_('Tags')) + menu_front_page.bind_links(links=[link_document_list_recent, link_document_list]) + menu_setup.bind_links(links=[link_document_type_setup]) + + # Document type links + menu_object.bind_links(links=[link_document_type_edit, link_document_type_filename_list, link_document_type_delete], sources=[DocumentType]) + menu_object.bind_links(links=[link_document_type_filename_edit, link_document_type_filename_delete], sources=[DocumentTypeFilename]) + menu_secondary.bind_links(links=[link_document_type_list, link_document_type_create], sources=[DocumentType, 'documents:document_type_create', 'documents:document_type_list']) + menu_sidebar.bind_links(links=[link_document_type_filename_create], sources=[DocumentTypeFilename, 'documents:document_type_filename_list', 'documents:document_type_filename_create']) + + # Register document facet links + menu_facet.bind_links(links=[link_document_preview], sources=[Document], position=0) + menu_facet.bind_links(links=[link_document_content], sources=[Document], position=1) + menu_facet.bind_links(links=[link_document_properties], sources=[Document], position=2) + menu_facet.bind_links(links=[link_document_events_view, link_document_version_list], sources=[Document], position=2) + + # Document actions + menu_facet.bind_links(links=[link_document_page_rotate_left, link_document_page_rotate_right, link_document_page_zoom_in, link_document_page_zoom_out, link_document_page_view_reset], sources=['documents:document_page_view']) + menu_object.bind_links(links=[link_document_version_revert, link_document_version_download], sources=[DocumentVersion]) + menu_multi_item.bind_links(links=[link_document_multiple_clear_transformations, link_document_multiple_delete, link_document_multiple_download, link_document_multiple_update_page_count, link_document_multiple_document_type_edit], sources=[Document]) + + # Document pages + menu_object.bind_links(links=[link_document_edit, link_document_document_type_edit, link_document_print, link_document_delete, link_document_download, link_document_clear_transformations, link_document_update_page_count], sources=[Document]) + menu_object.bind_links(links=[link_document_page_transformation_list, link_document_page_view, link_document_page_text, link_document_page_edit], sources=[DocumentPage]) + menu_sidebar.bind_links(links=[link_document_page_navigation_first, link_document_page_navigation_previous, link_document_page_navigation_next, link_document_page_navigation_last], sources=[DocumentPage]) + + menu_object.bind_links(links=[link_document_page_transformation_edit, link_document_page_transformation_delete], sources=[DocumentPageTransformation]) + menu_sidebar.bind_links(links=[link_document_page_transformation_create], sources=['documents:document_page_transformation_list']) + menu_sidebar.bind_links(links=[link_document_page_transformation_create], sources=['documents:document_page_transformation_create']) + menu_sidebar.bind_links(links=[link_document_page_transformation_create], sources=['documents:document_page_transformation_edit', 'documents:document_page_transformation_delete']) + namespace = StatisticNamespace(name='documents', label=_('Documents')) namespace.add_statistic(DocumentStatistics(name='document_stats', label=_('Document tendencies'))) namespace.add_statistic(DocumentUsageStatistics(name='document_usage', label=_('Document usage'))) registry.register(Document) + + register_maintenance_links([link_clear_image_cache], namespace='documents', title=_('Documents')) + register_model_list_columns(Document, [ + { + 'name': _('Thumbnail'), 'attribute': + encapsulate(lambda x: document_thumbnail(x, gallery_name='documents:document_list', title=getattr(x, 'filename', None), size=THUMBNAIL_SIZE)) + }, + { + 'name': _('Type'), 'attribute': 'document_type' + } + ]) diff --git a/mayan/apps/documents/links.py b/mayan/apps/documents/links.py index d07016db82..a0c759637d 100644 --- a/mayan/apps/documents/links.py +++ b/mayan/apps/documents/links.py @@ -15,7 +15,9 @@ from .permissions import ( ) from .settings import ZOOM_MAX_LEVEL, ZOOM_MIN_LEVEL -# Document page links expressions + +def is_current_version(context): + return context['object'].document.latest_version.timestamp == context['object'].timestamp def is_first_page(context): @@ -26,23 +28,19 @@ def is_last_page(context): return context['page'].page_number >= context['page'].document_version.pages.count() -def is_min_zoom(context): - return context['zoom'] <= ZOOM_MIN_LEVEL - - def is_max_zoom(context): return context['zoom'] >= ZOOM_MAX_LEVEL -def is_current_version(context): - return context['object'].document.latest_version.timestamp == context['object'].timestamp +def is_min_zoom(context): + return context['zoom'] <= ZOOM_MIN_LEVEL # Facet -link_document_preview = Link(permissions=[PERMISSION_DOCUMENT_VIEW], text=_('Preview'), view='documents:document_preview', args='object.id') link_document_content = Link(permissions=[PERMISSION_DOCUMENT_VIEW], text=_('Content'), view='documents:document_content', args='object.id') -link_document_properties = Link(permissions=[PERMISSION_DOCUMENT_VIEW], text=_('Properties'), view='documents:document_properties', args='object.id') link_document_events_view = Link(permissions=[PERMISSION_EVENTS_VIEW], text=_('Events'), view='events:events_for_object', args=['"documents"', '"document"', 'object.id']) +link_document_preview = Link(permissions=[PERMISSION_DOCUMENT_VIEW], text=_('Preview'), view='documents:document_preview', args='object.id') +link_document_properties = Link(permissions=[PERMISSION_DOCUMENT_VIEW], text=_('Properties'), view='documents:document_properties', args='object.id') link_document_version_list = Link(permissions=[PERMISSION_DOCUMENT_VIEW], text=_('Versions'), view='documents:document_version_list', args='object.pk') # Actions @@ -57,12 +55,12 @@ link_document_update_page_count = Link(permissions=[PERMISSION_DOCUMENT_TOOLS], # Views link_document_list = Link(icon='fa fa-file', text=_('All documents'), view='documents:document_list') link_document_list_recent = Link(icon='fa fa-clock-o', text=_('Recent documents'), view='documents:document_list_recent') +link_document_multiple_clear_transformations = Link(permissions=[PERMISSION_DOCUMENT_TRANSFORM], text=_('Clear transformations'), view='documents:document_multiple_clear_transformations') link_document_multiple_delete = Link(permissions=[PERMISSION_DOCUMENT_DELETE], text=_('Delete'), view='documents:document_multiple_delete') link_document_multiple_document_type_edit = Link(permissions=[PERMISSION_DOCUMENT_PROPERTIES_EDIT], text=_('Change type'), view='documents:document_multiple_document_type_edit') link_document_multiple_download = Link(permissions=[PERMISSION_DOCUMENT_DOWNLOAD], text=_('Download'), view='documents:document_multiple_download') -link_document_version_download = Link(args='object.pk', permissions=[PERMISSION_DOCUMENT_DOWNLOAD], text=_('Download'), view='documents:document_version_download') link_document_multiple_update_page_count = Link(permissions=[PERMISSION_DOCUMENT_TOOLS], text=_('Reset page count'), view= 'documents:document_multiple_update_page_count') -link_document_multiple_clear_transformations = Link(permissions=[PERMISSION_DOCUMENT_TRANSFORM], text=_('Clear transformations'), view='documents:document_multiple_clear_transformations') +link_document_version_download = Link(args='object.pk', permissions=[PERMISSION_DOCUMENT_DOWNLOAD], text=_('Download'), view='documents:document_version_download') # Tools link_clear_image_cache = Link( @@ -72,34 +70,33 @@ link_clear_image_cache = Link( ) # Document pages -link_document_page_transformation_list = Link(args='page.pk', klass='no-parent-history', permissions=[PERMISSION_DOCUMENT_TRANSFORM], text=_('Page transformations'), view='documents:document_page_transformation_list') link_document_page_transformation_create = Link(args='page.pk', klass='no-parent-history', permissions=[PERMISSION_DOCUMENT_TRANSFORM], text= _('Create new transformation'), view='documents:document_page_transformation_create') -link_document_page_transformation_edit = Link(args='transformation.pk', klass='no-parent-history', permissions=[PERMISSION_DOCUMENT_TRANSFORM], text=_('Edit'), view='documents:document_page_transformation_edit') link_document_page_transformation_delete = Link(args='transformation.pk', klass='no-parent-history', permissions=[PERMISSION_DOCUMENT_TRANSFORM], text=_('Delete'), view='documents:document_page_transformation_delete') -link_document_page_view = Link(args='page.pk', klass='no-parent-history', permissions=[PERMISSION_DOCUMENT_VIEW], text=_('Page image'), view='documents:document_page_view') -link_document_page_text = Link(args='page.pk', klass='no-parent-history', permissions=[PERMISSION_DOCUMENT_VIEW], text=_('Page text'), view='documents:document_page_text') +link_document_page_transformation_edit = Link(args='transformation.pk', klass='no-parent-history', permissions=[PERMISSION_DOCUMENT_TRANSFORM], text=_('Edit'), view='documents:document_page_transformation_edit') +link_document_page_transformation_list = Link(args='page.pk', klass='no-parent-history', permissions=[PERMISSION_DOCUMENT_TRANSFORM], text=_('Page transformations'), view='documents:document_page_transformation_list') link_document_page_edit = Link(klass='no-parent-history', permissions=[PERMISSION_DOCUMENT_EDIT], text=_('Edit page text'), view='documents:document_page_edit', args='page.pk') -link_document_page_navigation_next = Link(conditional_disable=is_last_page, keep_query=True, klass='no-parent-history', text=_('Next page'), permissions=[PERMISSION_DOCUMENT_VIEW], view='documents:document_page_navigation_next', args='page.pk') -link_document_page_navigation_previous = Link(conditional_disable=is_first_page, keep_query=True, klass='no-parent-history', permissions=[PERMISSION_DOCUMENT_VIEW], text=_('Previous page'), view='documents:document_page_navigation_previous', args='page.pk') link_document_page_navigation_first = Link(conditional_disable=is_first_page, keep_query=True, klass='no-parent-history', permissions=[PERMISSION_DOCUMENT_VIEW], text=_('First page'), view='documents:document_page_navigation_first', args='page.pk') link_document_page_navigation_last = Link(conditional_disable=is_last_page, keep_query=True, text=_('Last page'), klass='no-parent-history', permissions=[PERMISSION_DOCUMENT_VIEW], view='documents:document_page_navigation_last', args='page.pk') +link_document_page_navigation_previous = Link(conditional_disable=is_first_page, keep_query=True, klass='no-parent-history', permissions=[PERMISSION_DOCUMENT_VIEW], text=_('Previous page'), view='documents:document_page_navigation_previous', args='page.pk') +link_document_page_navigation_next = Link(conditional_disable=is_last_page, keep_query=True, klass='no-parent-history', text=_('Next page'), permissions=[PERMISSION_DOCUMENT_VIEW], view='documents:document_page_navigation_next', args='page.pk') +link_document_page_rotate_left = Link(klass='no-parent-history', permissions=[PERMISSION_DOCUMENT_VIEW], text=_('Rotate left'), view='documents:document_page_rotate_left', args='page.pk') +link_document_page_rotate_right = Link(klass='no-parent-history', permissions=[PERMISSION_DOCUMENT_VIEW], text=_('Rotate right'), view='documents:document_page_rotate_right', args='page.pk') +link_document_page_text = Link(args='page.pk', klass='no-parent-history', permissions=[PERMISSION_DOCUMENT_VIEW], text=_('Page text'), view='documents:document_page_text') +link_document_page_view = Link(args='page.pk', klass='no-parent-history', permissions=[PERMISSION_DOCUMENT_VIEW], text=_('Page image'), view='documents:document_page_view') +link_document_page_view_reset = Link(permissions=[PERMISSION_DOCUMENT_VIEW], klass='no-parent-history', text=_('Reset view'), view='documents:document_page_view_reset', args='page.pk') link_document_page_zoom_in = Link(conditional_disable=is_max_zoom, klass='no-parent-history', permissions=[PERMISSION_DOCUMENT_VIEW], text=_('Zoom in'), view='documents:document_page_zoom_in', args='page.pk') link_document_page_zoom_out = Link(conditional_disable=is_min_zoom, klass='no-parent-history', permissions=[PERMISSION_DOCUMENT_VIEW], text=_('Zoom out'), view='documents:document_page_zoom_out', args='page.pk') -link_document_page_rotate_right = Link(klass='no-parent-history', permissions=[PERMISSION_DOCUMENT_VIEW], text=_('Rotate right'), view='documents:document_page_rotate_right', args='page.pk') -link_document_page_rotate_left = Link(klass='no-parent-history', permissions=[PERMISSION_DOCUMENT_VIEW], text=_('Rotate left'), view='documents:document_page_rotate_left', args='page.pk') -link_document_page_view_reset = Link(permissions=[PERMISSION_DOCUMENT_VIEW], klass='no-parent-history', text=_('Reset view'), view='documents:document_page_view_reset', args='page.pk') # Document versions link_document_version_revert = Link(conditional_disable=is_current_version, permissions=[PERMISSION_DOCUMENT_VERSION_REVERT], text=_('Revert'), view='documents:document_version_revert', args='object.pk') # Document type related links +link_document_type_create = Link(permissions=[PERMISSION_DOCUMENT_TYPE_CREATE], text=_('Create document type'), view='documents:document_type_create') +link_document_type_delete = Link(permissions=[PERMISSION_DOCUMENT_TYPE_DELETE], text=_('Delete'), view='documents:document_type_delete', args='document_type.id') +link_document_type_edit = Link(permissions=[PERMISSION_DOCUMENT_TYPE_EDIT], text=_('Edit'), view='documents:document_type_edit', args='document_type.id') +link_document_type_filename_create = Link(permissions=[PERMISSION_DOCUMENT_TYPE_EDIT], text=_('Add filename to document type'), view='documents:document_type_filename_create', args='document_type.id') +link_document_type_filename_delete = Link(permissions=[PERMISSION_DOCUMENT_TYPE_EDIT], text=_('Delete'), view='documents:document_type_filename_delete', args='filename.id') +link_document_type_filename_edit = Link(permissions=[PERMISSION_DOCUMENT_TYPE_EDIT], text=_('Edit'), view='documents:document_type_filename_edit', args='filename.id') +link_document_type_filename_list = Link(permissions=[PERMISSION_DOCUMENT_TYPE_VIEW], text=_('Filenames'), view='documents:document_type_filename_list', args='document_type.id') link_document_type_list = Link(permissions=[PERMISSION_DOCUMENT_TYPE_VIEW], text=_('Document types'), view='documents:document_type_list') link_document_type_setup = Link(icon='fa fa-file', permissions=[PERMISSION_DOCUMENT_TYPE_VIEW], text=_('Document types'), view='documents:document_type_list') -link_document_type_edit = Link(permissions=[PERMISSION_DOCUMENT_TYPE_EDIT], text=_('Edit'), view='documents:document_type_edit', args='document_type.id') -link_document_type_delete = Link(permissions=[PERMISSION_DOCUMENT_TYPE_DELETE], text=_('Delete'), view='documents:document_type_delete', args='document_type.id') -link_document_type_create = Link(permissions=[PERMISSION_DOCUMENT_TYPE_CREATE], text=_('Create document type'), view='documents:document_type_create') - -link_document_type_filename_list = Link(permissions=[PERMISSION_DOCUMENT_TYPE_VIEW], text=_('Filenames'), view='documents:document_type_filename_list', args='document_type.id') -link_document_type_filename_create = Link(permissions=[PERMISSION_DOCUMENT_TYPE_EDIT], text=_('Add filename to document type'), view='documents:document_type_filename_create', args='document_type.id') -link_document_type_filename_edit = Link(permissions=[PERMISSION_DOCUMENT_TYPE_EDIT], text=_('Edit'), view='documents:document_type_filename_edit', args='filename.id') -link_document_type_filename_delete = Link(permissions=[PERMISSION_DOCUMENT_TYPE_EDIT], text=_('Delete'), view='documents:document_type_filename_delete', args='filename.id') diff --git a/mayan/apps/main/apps.py b/mayan/apps/main/apps.py index cad87fae83..60b1bbafe2 100644 --- a/mayan/apps/main/apps.py +++ b/mayan/apps/main/apps.py @@ -16,7 +16,7 @@ class MainApp(apps.AppConfig): verbose_name = _('Main') def ready(self): + menu_main.bind_links(links=[link_setup], position=-2) + menu_main.bind_links(links=[link_tools], position=-3) menu_setup.bind_links(links=[link_admin_site]) menu_tools.bind_links(links=[link_maintenance_menu]) - menu_main.bind_links(links=[link_tools], position=-3) - menu_main.bind_links(links=[link_setup], position=-2) diff --git a/mayan/apps/main/links.py b/mayan/apps/main/links.py index a62c0c7108..a147677002 100644 --- a/mayan/apps/main/links.py +++ b/mayan/apps/main/links.py @@ -9,7 +9,7 @@ def is_superuser(context): return context['request'].user.is_staff or context['request'].user.is_superuser -link_maintenance_menu = Link(icon='fa fa-wrench', text=_('Maintenance'), view='main:maintenance_menu') link_admin_site = Link(condition=is_superuser, icon='fa fa-keyboard-o', text=_('Admin site'), view='admin:index') +link_maintenance_menu = Link(icon='fa fa-wrench', text=_('Maintenance'), view='main:maintenance_menu') link_setup = Link(icon='fa fa-gear', text=_('Setup'), view='main:setup_list') link_tools = Link(icon='fa fa-wrench', text=_('Tools'), view='main:tools_list') diff --git a/mayan/apps/tags/apps.py b/mayan/apps/tags/apps.py index 6cc6e3094d..83373de908 100644 --- a/mayan/apps/tags/apps.py +++ b/mayan/apps/tags/apps.py @@ -51,6 +51,13 @@ class TagsApp(apps.AppConfig): menu_secondary.bind_links(links=[link_tag_list, link_tag_create], sources=[Tag, 'tags:tag_list', 'tags:tag_create']) menu_sidebar.bind_links(links=[link_tag_attach], sources=['tags:document_tags', 'tags:tag_remove', 'tags:tag_multiple_remove', 'tags:tag_attach']) + register_model_list_columns(Document, [ + { + 'name': _('Tags'), 'attribute': + encapsulate(lambda x: get_tags_inline_widget_simple(x)) + }, + ]) + register_model_list_columns(Tag, [ { 'name': _('Preview'), @@ -61,10 +68,3 @@ class TagsApp(apps.AppConfig): 'attribute': encapsulate(lambda x: x.documents.count()) } ]) - - register_model_list_columns(Document, [ - { - 'name': _('Tags'), 'attribute': - encapsulate(lambda x: get_tags_inline_widget_simple(x)) - }, - ])