Finish app navigation updates
This commit is contained in:
@@ -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'
|
||||
}
|
||||
])
|
||||
|
||||
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user