Update documents app
Rename the DeletedDocument proxy model to a TrashedDocument. Rename the deleted_document views to trashed_document. Rename the document and deleted_document URL parameters to trashed_document. Update URL parameters to the '_id' form. Add keyword arguments. Update use of .filter_by_access(). Enclose trashed document restore method in a transaction. Sort arguments. Update app for compliance with MERCs 5 and 6. Add document page view tests. Add favorite document view tests. Movernize tests. Replace use of urlencode with furl. Update views to use ExternalObjectMixin. Refactor the document and version download views. Rename the DocumentDocumentTypeEditView to DocumentChangeTypeView. Move the trashed document views to their own module. Signed-off-by: Roberto Rosario <Roberto.Rosario@mayan-edms.com>
This commit is contained in:
+124
-89
@@ -9,19 +9,18 @@ from mayan.apps.navigation import Link
|
||||
|
||||
from .icons import (
|
||||
icon_clear_image_cache, icon_document_duplicates_list, icon_document_list,
|
||||
icon_document_list_deleted, icon_document_list_favorites,
|
||||
icon_document_list_favorites,
|
||||
icon_document_list_recent_access, icon_document_list_recent_added,
|
||||
icon_document_delete, icon_document_download, icon_document_edit,
|
||||
icon_trashed_document_delete, icon_document_download, icon_document_edit,
|
||||
icon_document_favorites_add, icon_document_favorites_remove,
|
||||
icon_document_multiple_delete,
|
||||
icon_document_multiple_restore, icon_document_page_navigation_first,
|
||||
icon_document_page_navigation_first,
|
||||
icon_document_page_navigation_last,
|
||||
icon_document_page_navigation_next, icon_document_page_navigation_previous,
|
||||
icon_document_page_return, icon_document_page_rotate_left,
|
||||
icon_document_page_rotate_right, icon_document_page_view,
|
||||
icon_document_page_view_reset, icon_document_page_zoom_in,
|
||||
icon_document_page_zoom_out, icon_document_pages, icon_document_preview,
|
||||
icon_document_print, icon_document_properties, icon_document_restore,
|
||||
icon_document_print, icon_document_properties, icon_trashed_document_restore,
|
||||
icon_document_trash, icon_document_type_create,
|
||||
icon_document_type_delete, icon_document_type_edit,
|
||||
icon_document_type_filename, icon_document_type_filename_create,
|
||||
@@ -30,17 +29,20 @@ from .icons import (
|
||||
icon_document_version_list, icon_document_version_return_document,
|
||||
icon_document_version_return_list, icon_document_version_view,
|
||||
icon_duplicated_document_list, icon_duplicated_document_scan,
|
||||
icon_trash_can_empty
|
||||
icon_trash_can_empty,
|
||||
icon_trashed_document_list,
|
||||
icon_trashed_document_multiple_delete,
|
||||
icon_trashed_document_multiple_restore,
|
||||
)
|
||||
from .permissions import (
|
||||
permission_document_delete, permission_document_download,
|
||||
permission_document_print, permission_document_properties_edit,
|
||||
permission_document_restore, permission_document_tools,
|
||||
permission_document_download, permission_document_print,
|
||||
permission_document_properties_edit, permission_document_tools,
|
||||
permission_document_trash, permission_document_type_create,
|
||||
permission_document_type_delete, permission_document_type_edit,
|
||||
permission_document_type_view, permission_document_version_revert,
|
||||
permission_document_version_view, permission_document_view,
|
||||
permission_empty_trash
|
||||
permission_empty_trash, permission_trashed_document_delete,
|
||||
permission_trashed_document_restore
|
||||
)
|
||||
from .settings import setting_zoom_max_level, setting_zoom_min_level
|
||||
|
||||
@@ -74,22 +76,26 @@ def is_min_zoom(context):
|
||||
|
||||
# Facet
|
||||
link_document_preview = Link(
|
||||
args='resolved_object.id', icon_class=icon_document_preview,
|
||||
icon_class=icon_document_preview,
|
||||
kwargs={'document_id': 'resolved_object.id'},
|
||||
permission=permission_document_view, text=_('Preview'),
|
||||
view='documents:document_preview'
|
||||
)
|
||||
link_document_properties = Link(
|
||||
args='resolved_object.id', icon_class=icon_document_properties,
|
||||
icon_class=icon_document_properties,
|
||||
kwargs={'document_id': 'resolved_object.id'},
|
||||
permission=permission_document_view, text=_('Properties'),
|
||||
view='documents:document_properties'
|
||||
)
|
||||
link_document_version_list = Link(
|
||||
args='resolved_object.pk', icon_class=icon_document_version_list,
|
||||
icon_class=icon_document_version_list,
|
||||
kwargs={'document_id': 'resolved_object.id'},
|
||||
permission=permission_document_version_view, text=_('Versions'),
|
||||
view='documents:document_version_list'
|
||||
)
|
||||
link_document_pages = Link(
|
||||
args='resolved_object.pk', icon_class=icon_document_pages,
|
||||
icon_class=icon_document_pages,
|
||||
kwargs={'document_id': 'resolved_object.id'},
|
||||
permission=permission_document_view, text=_('Pages'),
|
||||
view='documents:document_pages'
|
||||
)
|
||||
@@ -97,68 +103,68 @@ link_document_pages = Link(
|
||||
# Actions
|
||||
link_document_clear_transformations = Link(
|
||||
args='resolved_object.id', permission=permission_transformation_delete,
|
||||
kwargs={'document_id': 'resolved_object.id'},
|
||||
text=_('Clear transformations'),
|
||||
view='documents:document_clear_transformations'
|
||||
)
|
||||
link_document_clone_transformations = Link(
|
||||
args='resolved_object.id', permission=permission_transformation_edit,
|
||||
permission=permission_transformation_edit,
|
||||
kwargs={'document_id': 'resolved_object.id'},
|
||||
text=_('Clone transformations'),
|
||||
view='documents:document_clone_transformations'
|
||||
)
|
||||
link_document_delete = Link(
|
||||
args='resolved_object.id', icon_class=icon_document_delete,
|
||||
permission=permission_document_delete, tags='dangerous',
|
||||
text=_('Delete'), view='documents:document_delete'
|
||||
)
|
||||
link_document_favorites_add = Link(
|
||||
args='resolved_object.id', icon_class=icon_document_favorites_add,
|
||||
icon_class=icon_document_favorites_add,
|
||||
kwargs={'document_id': 'resolved_object.id'},
|
||||
permission=permission_document_view, text=_('Add to favorites'),
|
||||
view='documents:document_add_to_favorites'
|
||||
)
|
||||
link_document_favorites_remove = Link(
|
||||
args='resolved_object.id', icon_class=icon_document_favorites_remove,
|
||||
icon_class=icon_document_favorites_remove,
|
||||
kwargs={'document_id': 'resolved_object.id'},
|
||||
permission=permission_document_view, text=_('Remove from favorites'),
|
||||
view='documents:document_remove_from_favorites'
|
||||
)
|
||||
link_document_trash = Link(
|
||||
args='resolved_object.id', icon_class=icon_document_trash,
|
||||
icon_class=icon_document_trash,
|
||||
kwargs={'document_id': 'resolved_object.id'},
|
||||
permission=permission_document_trash, tags='dangerous',
|
||||
text=_('Move to trash'), view='documents:document_trash'
|
||||
)
|
||||
link_document_edit = Link(
|
||||
args='resolved_object.id', icon_class=icon_document_edit,
|
||||
icon_class=icon_document_edit,
|
||||
kwargs={'document_id': 'resolved_object.id'},
|
||||
permission=permission_document_properties_edit,
|
||||
text=_('Edit properties'), view='documents:document_edit'
|
||||
)
|
||||
link_document_document_type_edit = Link(
|
||||
args='resolved_object.id',
|
||||
link_document_change_type = Link(
|
||||
kwargs={'document_id': 'resolved_object.id'},
|
||||
permission=permission_document_properties_edit, text=_('Change type'),
|
||||
view='documents:document_document_type_edit'
|
||||
view='documents:document_change_type'
|
||||
)
|
||||
link_document_download = Link(
|
||||
args='resolved_object.id', icon_class=icon_document_download,
|
||||
icon_class=icon_document_download,
|
||||
kwargs={'document_id': 'resolved_object.id'},
|
||||
permission=permission_document_download, text=_('Advanced download'),
|
||||
view='documents:document_download_form'
|
||||
)
|
||||
link_document_print = Link(
|
||||
args='resolved_object.id', icon_class=icon_document_print,
|
||||
icon_class=icon_document_print,
|
||||
kwargs={'document_id': 'resolved_object.id'},
|
||||
permission=permission_document_print, text=_('Print'),
|
||||
view='documents:document_print'
|
||||
)
|
||||
link_document_quick_download = Link(
|
||||
args='resolved_object.id', permission=permission_document_download,
|
||||
permission=permission_document_download,
|
||||
kwargs={'document_id': 'resolved_object.id'},
|
||||
text=_('Quick download'), view='documents:document_download'
|
||||
)
|
||||
link_document_update_page_count = Link(
|
||||
args='resolved_object.pk', permission=permission_document_tools,
|
||||
kwargs={'document_id': 'resolved_object.id'},
|
||||
permission=permission_document_tools,
|
||||
text=_('Recalculate page count'),
|
||||
view='documents:document_update_page_count'
|
||||
)
|
||||
link_document_restore = Link(
|
||||
args='object.pk', icon_class=icon_document_restore,
|
||||
permission=permission_document_restore, text=_('Restore'),
|
||||
view='documents:document_restore'
|
||||
)
|
||||
link_document_multiple_clear_transformations = Link(
|
||||
permission=permission_transformation_delete,
|
||||
text=_('Clear transformations'),
|
||||
@@ -168,10 +174,6 @@ link_document_multiple_trash = Link(
|
||||
tags='dangerous', text=_('Move to trash'),
|
||||
view='documents:document_multiple_trash'
|
||||
)
|
||||
link_document_multiple_delete = Link(
|
||||
icon_class=icon_document_multiple_delete, tags='dangerous',
|
||||
text=_('Delete'), view='documents:document_multiple_delete'
|
||||
)
|
||||
link_document_multiple_favorites_add = Link(
|
||||
text=_('Add to favorites'),
|
||||
view='documents:document_multiple_add_to_favorites'
|
||||
@@ -180,9 +182,9 @@ link_document_multiple_favorites_remove = Link(
|
||||
text=_('Remove from favorites'),
|
||||
view='documents:document_multiple_remove_from_favorites'
|
||||
)
|
||||
link_document_multiple_document_type_edit = Link(
|
||||
link_document_multiple_change_type = Link(
|
||||
text=_('Change type'),
|
||||
view='documents:document_multiple_document_type_edit'
|
||||
view='documents:document_multiple_change_type'
|
||||
)
|
||||
link_document_multiple_download = Link(
|
||||
text=_('Advanced download'),
|
||||
@@ -192,31 +194,54 @@ link_document_multiple_update_page_count = Link(
|
||||
text=_('Recalculate page count'),
|
||||
view='documents:document_multiple_update_page_count'
|
||||
)
|
||||
link_document_multiple_restore = Link(
|
||||
icon_class=icon_document_multiple_restore, text=_('Restore'),
|
||||
view='documents:document_multiple_restore'
|
||||
|
||||
link_trashed_document_delete = Link(
|
||||
icon_class=icon_trashed_document_delete,
|
||||
kwargs={'trashed_document_id': 'resolved_object.id'},
|
||||
permission=permission_trashed_document_delete, tags='dangerous',
|
||||
text=_('Delete'), view='documents:trashed_document_delete'
|
||||
)
|
||||
link_trashed_document_list = Link(
|
||||
icon_class=icon_trashed_document_list, text=_('Trash can'),
|
||||
view='documents:trashed_document_list'
|
||||
)
|
||||
link_trashed_document_restore = Link(
|
||||
icon_class=icon_trashed_document_restore,
|
||||
kwargs={'trashed_document_id': 'resolved_object.id'},
|
||||
permission=permission_trashed_document_restore, text=_('Restore'),
|
||||
view='documents:trashed_document_restore'
|
||||
)
|
||||
link_trashed_document_multiple_delete = Link(
|
||||
icon_class=icon_trashed_document_multiple_delete, tags='dangerous',
|
||||
text=_('Delete'), view='documents:trashed_document_multiple_delete'
|
||||
)
|
||||
link_trashed_document_multiple_restore = Link(
|
||||
icon_class=icon_trashed_document_multiple_restore, text=_('Restore'),
|
||||
view='documents:trashed_document_multiple_restore'
|
||||
)
|
||||
|
||||
# Versions
|
||||
link_document_version_download = Link(
|
||||
args='resolved_object.pk', icon_class=icon_document_version_download,
|
||||
icon_class=icon_document_version_download,
|
||||
kwargs={'document_version_id': 'resolved_object.pk'},
|
||||
permission=permission_document_download, text=_('Download version'),
|
||||
view='documents:document_version_download_form'
|
||||
)
|
||||
link_document_version_return_document = Link(
|
||||
args='resolved_object.document.pk',
|
||||
icon_class=icon_document_version_return_document,
|
||||
kwargs={'document_id': 'resolved_object.document.pk'},
|
||||
permission=permission_document_view, text=_('Document'),
|
||||
view='documents:document_preview'
|
||||
)
|
||||
link_document_version_return_list = Link(
|
||||
args='resolved_object.document.pk',
|
||||
icon_class=icon_document_version_return_list,
|
||||
kwargs={'document_id': 'resolved_object.document.pk'},
|
||||
permission=permission_document_version_view, text=_('Versions'),
|
||||
view='documents:document_version_list'
|
||||
)
|
||||
link_document_version_view = Link(
|
||||
args='resolved_object.pk', icon_class=icon_document_version_view,
|
||||
icon_class=icon_document_version_view,
|
||||
kwargs={'document_version_id': 'resolved_object.pk'},
|
||||
permission=permission_document_version_view, text=_('Preview'),
|
||||
view='documents:document_version_view'
|
||||
)
|
||||
@@ -238,10 +263,6 @@ link_document_list_recent_added = Link(
|
||||
icon_class=icon_document_list_recent_added, text=_('Recently added'),
|
||||
view='documents:document_list_recent_added'
|
||||
)
|
||||
link_document_list_deleted = Link(
|
||||
icon_class=icon_document_list_deleted, text=_('Trash can'),
|
||||
view='documents:document_list_deleted'
|
||||
)
|
||||
|
||||
# Tools
|
||||
link_clear_image_cache = Link(
|
||||
@@ -260,73 +281,80 @@ link_trash_can_empty = Link(
|
||||
|
||||
# Document pages
|
||||
link_document_page_navigation_first = Link(
|
||||
args='resolved_object.pk', conditional_disable=is_first_page,
|
||||
icon_class=icon_document_page_navigation_first,
|
||||
keep_query=True, permission=permission_document_view,
|
||||
text=_('First page'), view='documents:document_page_navigation_first'
|
||||
conditional_disable=is_first_page,
|
||||
icon_class=icon_document_page_navigation_first, keep_query=True,
|
||||
kwargs={'document_page_id': 'resolved_object.pk'},
|
||||
permission=permission_document_view, text=_('First page'),
|
||||
view='documents:document_page_navigation_first'
|
||||
)
|
||||
link_document_page_navigation_last = Link(
|
||||
args='resolved_object.pk', conditional_disable=is_last_page,
|
||||
icon_class=icon_document_page_navigation_last,
|
||||
keep_query=True, text=_('Last page'),
|
||||
permission=permission_document_view,
|
||||
conditional_disable=is_last_page,
|
||||
icon_class=icon_document_page_navigation_last, keep_query=True,
|
||||
kwargs={'document_page_id': 'resolved_object.pk'},
|
||||
permission=permission_document_view, text=_('Last page'),
|
||||
view='documents:document_page_navigation_last'
|
||||
)
|
||||
link_document_page_navigation_previous = Link(
|
||||
args='resolved_object.pk', conditional_disable=is_first_page,
|
||||
icon_class=icon_document_page_navigation_previous,
|
||||
keep_query=True, permission=permission_document_view,
|
||||
text=_('Previous page'),
|
||||
conditional_disable=is_first_page,
|
||||
icon_class=icon_document_page_navigation_previous, keep_query=True,
|
||||
kwargs={'document_page_id': 'resolved_object.pk'},
|
||||
permission=permission_document_view, text=_('Previous page'),
|
||||
view='documents:document_page_navigation_previous'
|
||||
)
|
||||
link_document_page_navigation_next = Link(
|
||||
args='resolved_object.pk', conditional_disable=is_last_page,
|
||||
icon_class=icon_document_page_navigation_next,
|
||||
keep_query=True, text=_('Next page'),
|
||||
conditional_disable=is_last_page,
|
||||
icon_class=icon_document_page_navigation_next, keep_query=True,
|
||||
kwargs={'document_page_id': 'resolved_object.pk'}, text=_('Next page'),
|
||||
permission=permission_document_view,
|
||||
view='documents:document_page_navigation_next'
|
||||
)
|
||||
link_document_page_return = Link(
|
||||
args='resolved_object.document.pk', icon_class=icon_document_page_return,
|
||||
icon_class=icon_document_page_return,
|
||||
kwargs={'document_id': 'resolved_object.document.pk'},
|
||||
permission=permission_document_view, text=_('Document'),
|
||||
view='documents:document_preview'
|
||||
)
|
||||
link_document_page_rotate_left = Link(
|
||||
args='resolved_object.pk', icon_class=icon_document_page_rotate_left,
|
||||
keep_query=True, permission=permission_document_view,
|
||||
text=_('Rotate left'), view='documents:document_page_rotate_left'
|
||||
icon_class=icon_document_page_rotate_left, keep_query=True,
|
||||
kwargs={'document_page_id': 'resolved_object.pk'},
|
||||
permission=permission_document_view, text=_('Rotate left'),
|
||||
view='documents:document_page_rotate_left'
|
||||
)
|
||||
link_document_page_rotate_right = Link(
|
||||
args='resolved_object.pk', icon_class=icon_document_page_rotate_right,
|
||||
keep_query=True, permission=permission_document_view,
|
||||
text=_('Rotate right'), view='documents:document_page_rotate_right'
|
||||
icon_class=icon_document_page_rotate_right, keep_query=True,
|
||||
kwargs={'document_page_id': 'resolved_object.pk'},
|
||||
permission=permission_document_view, text=_('Rotate right'),
|
||||
view='documents:document_page_rotate_right'
|
||||
)
|
||||
link_document_page_view = Link(
|
||||
icon_class=icon_document_page_view,
|
||||
kwargs={'document_page_id': 'resolved_object.pk'},
|
||||
permission=permission_document_view, text=_('Page image'),
|
||||
view='documents:document_page_view', args='resolved_object.pk'
|
||||
view='documents:document_page_view'
|
||||
)
|
||||
link_document_page_view_reset = Link(
|
||||
icon_class=icon_document_page_view_reset,
|
||||
kwargs={'document_page_id': 'resolved_object.pk'},
|
||||
permission=permission_document_view, text=_('Reset view'),
|
||||
view='documents:document_page_view_reset', args='resolved_object.pk'
|
||||
view='documents:document_page_view_reset'
|
||||
)
|
||||
link_document_page_zoom_in = Link(
|
||||
args='resolved_object.pk', conditional_disable=is_max_zoom,
|
||||
icon_class=icon_document_page_zoom_in, keep_query=True,
|
||||
conditional_disable=is_max_zoom, icon_class=icon_document_page_zoom_in,
|
||||
keep_query=True, kwargs={'document_page_id': 'resolved_object.pk'},
|
||||
permission=permission_document_view, text=_('Zoom in'),
|
||||
view='documents:document_page_zoom_in'
|
||||
)
|
||||
link_document_page_zoom_out = Link(
|
||||
args='resolved_object.pk', conditional_disable=is_min_zoom,
|
||||
icon_class=icon_document_page_zoom_out, keep_query=True,
|
||||
conditional_disable=is_min_zoom, icon_class=icon_document_page_zoom_out,
|
||||
keep_query=True, kwargs={'document_page_id': 'resolved_object.pk'},
|
||||
permission=permission_document_view, text=_('Zoom out'),
|
||||
view='documents:document_page_zoom_out'
|
||||
)
|
||||
|
||||
# Document versions
|
||||
link_document_version_revert = Link(
|
||||
args='object.pk', condition=is_not_current_version,
|
||||
condition=is_not_current_version,
|
||||
kwargs={'document_version_id': 'object.pk'},
|
||||
permission=permission_document_version_revert, tags='dangerous',
|
||||
text=_('Revert'), view='documents:document_version_revert'
|
||||
)
|
||||
@@ -338,32 +366,38 @@ link_document_type_create = Link(
|
||||
text=_('Create document type'), view='documents:document_type_create'
|
||||
)
|
||||
link_document_type_delete = Link(
|
||||
args='resolved_object.id', icon_class=icon_document_type_delete,
|
||||
icon_class=icon_document_type_delete,
|
||||
kwargs={'document_type_id': 'resolved_object.pk'},
|
||||
permission=permission_document_type_delete, tags='dangerous',
|
||||
text=_('Delete'), view='documents:document_type_delete'
|
||||
)
|
||||
link_document_type_edit = Link(
|
||||
args='resolved_object.id', icon_class=icon_document_type_edit,
|
||||
icon_class=icon_document_type_edit,
|
||||
kwargs={'document_type_id': 'resolved_object.pk'},
|
||||
permission=permission_document_type_edit, text=_('Edit'),
|
||||
view='documents:document_type_edit'
|
||||
)
|
||||
link_document_type_filename_create = Link(
|
||||
args='document_type.id', icon_class=icon_document_type_filename_create,
|
||||
icon_class=icon_document_type_filename_create,
|
||||
kwargs={'document_type_id': 'resolved_object.pk'},
|
||||
permission=permission_document_type_edit,
|
||||
text=_('Add quick label to document type'),
|
||||
view='documents:document_type_filename_create'
|
||||
)
|
||||
link_document_type_filename_delete = Link(
|
||||
args='resolved_object.id', permission=permission_document_type_edit,
|
||||
kwargs={'filename_id': 'resolved_object.pk'},
|
||||
permission=permission_document_type_edit,
|
||||
tags='dangerous', text=_('Delete'),
|
||||
view='documents:document_type_filename_delete'
|
||||
)
|
||||
link_document_type_filename_edit = Link(
|
||||
args='resolved_object.id', permission=permission_document_type_edit,
|
||||
kwargs={'filename_id': 'resolved_object.pk'},
|
||||
permission=permission_document_type_edit,
|
||||
text=_('Edit'), view='documents:document_type_filename_edit'
|
||||
)
|
||||
link_document_type_filename_list = Link(
|
||||
args='resolved_object.id', icon_class=icon_document_type_filename,
|
||||
icon_class=icon_document_type_filename,
|
||||
kwargs={'document_type_id': 'resolved_object.pk'},
|
||||
permission=permission_document_type_view, text=_('Quick labels'),
|
||||
view='documents:document_type_filename_list'
|
||||
)
|
||||
@@ -382,7 +416,8 @@ link_duplicated_document_list = Link(
|
||||
view='documents:duplicated_document_list'
|
||||
)
|
||||
link_document_duplicates_list = Link(
|
||||
args='resolved_object.id', icon_class=icon_document_duplicates_list,
|
||||
icon_class=icon_document_duplicates_list,
|
||||
kwargs={'document_id': 'resolved_object.pk'},
|
||||
permission=permission_document_view, text=_('Duplicates'),
|
||||
view='documents:document_duplicates_list'
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user