Move link conversions, consolidate FrontPageLink with new link class
This commit is contained in:
@@ -9,11 +9,14 @@ from actstream import registry
|
||||
|
||||
from acls.api import class_permissions
|
||||
from common.classes import ModelAttribute
|
||||
from common import menu_facet, menu_object, menu_setup
|
||||
from common import (
|
||||
menu_facet, menu_front_page, menu_object, menu_secondary, menu_setup,
|
||||
menu_sidebar, menu_multi_item
|
||||
)
|
||||
from common.utils import encapsulate, validate_path
|
||||
from dynamic_search.classes import SearchModel
|
||||
from events.permissions import PERMISSION_EVENTS_VIEW
|
||||
from main import FrontPageButton, MissingItem
|
||||
from main import MissingItem
|
||||
from main.api import register_maintenance_links
|
||||
from navigation.api import register_model_list_columns
|
||||
from rest_api.classes import APIEndPoint
|
||||
@@ -22,25 +25,31 @@ from statistics.classes import StatisticNamespace
|
||||
from documents import settings as document_settings
|
||||
from .links import (
|
||||
link_clear_image_cache, link_document_clear_transformations,
|
||||
link_document_content, link_document_delete, link_document_document_type_edit,
|
||||
link_document_events_view, document_multiple_document_type_edit,
|
||||
link_document_download, link_document_edit, link_document_list, link_document_list_recent,
|
||||
document_multiple_delete, document_multiple_clear_transformations,
|
||||
document_multiple_download, document_multiple_update_page_count,
|
||||
document_page_edit, document_page_navigation_first,
|
||||
document_page_navigation_last, document_page_navigation_next,
|
||||
document_page_navigation_previous, document_page_rotate_left,
|
||||
document_page_rotate_right, document_page_text,
|
||||
document_page_transformation_list, document_page_transformation_create,
|
||||
document_page_transformation_edit, document_page_transformation_delete,
|
||||
document_page_view, document_page_view_reset, document_page_zoom_in,
|
||||
document_page_zoom_out, link_document_preview, link_document_print,
|
||||
link_document_properties, document_type_create, document_type_delete,
|
||||
document_type_edit, document_type_filename_create,
|
||||
document_type_filename_delete, document_type_filename_edit,
|
||||
document_type_filename_list, document_type_list, link_document_type_setup,
|
||||
link_document_update_page_count, document_version_download,
|
||||
link_document_version_list, document_version_revert
|
||||
link_document_content, link_document_delete,
|
||||
link_document_document_type_edit, link_document_events_view,
|
||||
link_document_multiple_document_type_edit, link_document_download,
|
||||
link_document_edit, link_document_list, link_document_list_recent,
|
||||
link_document_multiple_delete,
|
||||
link_document_multiple_clear_transformations,
|
||||
link_document_multiple_download,
|
||||
link_document_multiple_update_page_count, link_document_page_edit,
|
||||
link_document_page_navigation_first, link_document_page_navigation_last,
|
||||
link_document_page_navigation_next,
|
||||
link_document_page_navigation_previous, link_document_page_rotate_left,
|
||||
link_document_page_rotate_right, link_document_page_text,
|
||||
link_document_page_transformation_list,
|
||||
link_document_page_transformation_create,
|
||||
link_document_page_transformation_edit,
|
||||
link_document_page_transformation_delete, link_document_page_view,
|
||||
link_document_page_view_reset, link_document_page_zoom_in,
|
||||
link_document_page_zoom_out, link_document_preview, link_document_print,
|
||||
link_document_properties, link_document_type_create,
|
||||
link_document_type_delete, link_document_type_edit,
|
||||
link_document_type_filename_create, link_document_type_filename_delete,
|
||||
link_document_type_filename_edit, link_document_type_filename_list,
|
||||
link_document_type_list, link_document_type_setup,
|
||||
link_document_update_page_count, link_document_version_download,
|
||||
link_document_version_list, link_document_version_revert
|
||||
)
|
||||
from .models import (
|
||||
Document, DocumentPage, DocumentPageTransformation, DocumentType,
|
||||
@@ -62,11 +71,20 @@ 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
|
||||
#register_links(DocumentType, [document_type_edit, document_type_filename_list, document_type_delete])
|
||||
#register_links([DocumentType, 'documents:document_type_create', 'documents:document_type_list'], [document_type_list, document_type_create], menu_name='secondary_menu')
|
||||
#register_links(DocumentTypeFilename, [document_type_filename_edit, document_type_filename_delete])
|
||||
#register_links([DocumentTypeFilename, 'documents:document_type_filename_list', 'documents:document_type_filename_create'], [document_type_filename_create], menu_name='sidebar')
|
||||
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)
|
||||
@@ -77,24 +95,14 @@ class DocumentsApp(apps.AppConfig):
|
||||
# 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])
|
||||
|
||||
#register_links([Document], [document_multiple_clear_transformations, document_multiple_delete, document_multiple_download, document_multiple_update_page_count, document_multiple_document_type_edit, link_spacer], menu_name='multi_item_links')
|
||||
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])
|
||||
|
||||
# Document Version links
|
||||
#register_links(DocumentVersion, [document_version_revert, document_version_download])
|
||||
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])
|
||||
|
||||
# Document page links
|
||||
#register_links(DocumentPage, [
|
||||
# document_page_transformation_list, document_page_view,
|
||||
# document_page_text, document_page_edit,
|
||||
#])
|
||||
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'])
|
||||
|
||||
# Document page navigation links
|
||||
#register_links(DocumentPage, [
|
||||
# document_page_navigation_first, document_page_navigation_previous,
|
||||
# document_page_navigation_next, document_page_navigation_last
|
||||
#], menu_name='sidebar')
|
||||
|
||||
#register_links(['documents:document_page_view'], [document_page_rotate_left, document_page_rotate_right, document_page_zoom_in, document_page_zoom_out, document_page_view_reset], menu_name='form_header')
|
||||
#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')
|
||||
@@ -141,15 +149,4 @@ class DocumentsApp(apps.AppConfig):
|
||||
namespace.add_statistic(DocumentStatistics(name='document_stats', label=_('Document tendencies')))
|
||||
namespace.add_statistic(DocumentUsageStatistics(name='document_usage', label=_('Document usage')))
|
||||
|
||||
APIEndPoint('documents')
|
||||
|
||||
ModelAttribute(Document, label=_('Label'), name='label', type_name='field')
|
||||
|
||||
FrontPageButton(link=link_document_list_recent)
|
||||
FrontPageButton(link=link_document_list)
|
||||
|
||||
registry.register(Document)
|
||||
|
||||
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')
|
||||
|
||||
Reference in New Issue
Block a user