Add support for emptying the trash can in a single action.
This commit is contained in:
@@ -49,7 +49,7 @@ from .links import (
|
||||
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
|
||||
link_document_version_revert, link_trash_can_empty
|
||||
)
|
||||
from .models import (
|
||||
DeletedDocument, Document, DocumentPage, DocumentType, DocumentTypeFilename,
|
||||
@@ -94,6 +94,10 @@ class DocumentsApp(MayanAppConfig):
|
||||
)
|
||||
)
|
||||
|
||||
SourceColumn(source=Document, label=_('Thumbnail'), attribute=encapsulate(lambda document: document_thumbnail(document, gallery_name='documents:document_list', title=getattr(document, 'label', None), size=setting_thumbnail_size.value)))
|
||||
SourceColumn(source=Document, label=_('Type'), attribute='document_type')
|
||||
SourceColumn(source=DeletedDocument, label=_('Type'), attribute='document_type')
|
||||
|
||||
menu_front_page.bind_links(links=[link_document_list_recent, link_document_list, link_document_list_deleted])
|
||||
menu_setup.bind_links(links=[link_document_type_setup])
|
||||
menu_tools.bind_links(links=[link_clear_image_cache])
|
||||
@@ -104,6 +108,8 @@ class DocumentsApp(MayanAppConfig):
|
||||
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'])
|
||||
|
||||
menu_sidebar.bind_links(links=[link_trash_can_empty], sources=['documents:document_list_deleted', 'documents:trash_can_empty'])
|
||||
|
||||
# Document object links
|
||||
menu_object.bind_links(links=[link_document_edit, link_document_document_type_edit, link_document_print, link_document_trash, link_document_download, link_document_clear_transformations, link_document_update_page_count], sources=[Document])
|
||||
menu_object.bind_links(links=[link_document_restore, link_document_delete], sources=[DeletedDocument])
|
||||
@@ -133,6 +139,3 @@ class DocumentsApp(MayanAppConfig):
|
||||
post_initial_setup.connect(create_default_document_type, dispatch_uid='create_default_document_type')
|
||||
|
||||
registry.register(Document)
|
||||
|
||||
SourceColumn(source=Document, label=_('Thumbnail'), attribute=encapsulate(lambda document: document_thumbnail(document, gallery_name='documents:document_list', title=getattr(document, 'label', None), size=setting_thumbnail_size.value)))
|
||||
SourceColumn(source=Document, label=_('type'), attribute='document_type')
|
||||
|
||||
@@ -13,7 +13,7 @@ from .permissions import (
|
||||
permission_document_version_revert, permission_document_view,
|
||||
permission_document_trash, permission_document_type_create,
|
||||
permission_document_type_delete, permission_document_type_edit,
|
||||
permission_document_type_view
|
||||
permission_document_type_view, permission_empty_trash
|
||||
)
|
||||
from .settings import setting_zoom_max_level, setting_zoom_min_level
|
||||
|
||||
@@ -76,6 +76,7 @@ link_clear_image_cache = Link(
|
||||
permissions=[permission_document_tools], text=_('Clear image cache'),
|
||||
view='documents:document_clear_image_cache'
|
||||
)
|
||||
link_trash_can_empty = Link(permissions=[permission_empty_trash], text=_('Empty trash can'), view='documents:trash_can_empty')
|
||||
|
||||
# Document pages
|
||||
link_document_page_navigation_first = Link(conditional_disable=is_first_page, icon='fa fa-step-backward', keep_query=True, permissions=[permission_document_view], text=_('First page'), view='documents:document_page_navigation_first', args='resolved_object.pk')
|
||||
|
||||
@@ -19,6 +19,8 @@ permission_document_tools = namespace.add_permission(name='document_tools', labe
|
||||
permission_document_version_revert = namespace.add_permission(name='document_version_revert', label=_('Revert documents to a previous version'))
|
||||
permission_document_view = namespace.add_permission(name='document_view', label=_('View documents'))
|
||||
|
||||
permission_empty_trash = namespace.add_permission(name='document_empty_trash', label=_('Empty trash'))
|
||||
|
||||
setup_namespace = PermissionNamespace('documents_setup', label=_('Documents setup'))
|
||||
|
||||
permission_document_type_create = setup_namespace.add_permission(name='document_type_create', label=_('Create document types'))
|
||||
|
||||
@@ -13,7 +13,7 @@ from .settings import setting_print_size, setting_display_size
|
||||
from .views import (
|
||||
DeletedDocumentDeleteView, DeletedDocumentListView, DocumentListView,
|
||||
DocumentManyDeleteView, DocumentManyRestoreView, DocumentPageListView,
|
||||
DocumentRestoreView, RecentDocumentListView
|
||||
DocumentRestoreView, EmptyTrashCanView, RecentDocumentListView
|
||||
)
|
||||
|
||||
urlpatterns = patterns(
|
||||
@@ -52,6 +52,7 @@ urlpatterns = patterns(
|
||||
|
||||
url(r'^multiple/clear_transformations/$', 'document_multiple_clear_transformations', name='document_multiple_clear_transformations'),
|
||||
url(r'^maintenance/clear_image_cache/$', 'document_clear_image_cache', name='document_clear_image_cache'),
|
||||
url(r'^trash_can/empty/$', EmptyTrashCanView.as_view(), name='trash_can_empty'),
|
||||
|
||||
url(r'^page/(?P<document_page_id>\d+)/$', 'document_page_view', name='document_page_view'),
|
||||
url(r'^page/(?P<document_page_id>\d+)/navigation/next/$', 'document_page_navigation_next', name='document_page_navigation_next'),
|
||||
|
||||
@@ -7,7 +7,7 @@ import urlparse
|
||||
from django.conf import settings
|
||||
from django.contrib import messages
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.core.urlresolvers import resolve, reverse
|
||||
from django.core.urlresolvers import resolve, reverse, reverse_lazy
|
||||
from django.http import HttpResponse, HttpResponseRedirect
|
||||
from django.shortcuts import render_to_response, get_object_or_404
|
||||
from django.template import RequestContext
|
||||
@@ -48,7 +48,7 @@ from .permissions import (
|
||||
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_view,
|
||||
permission_document_view, permission_empty_trash
|
||||
)
|
||||
from .settings import (
|
||||
setting_preview_size, setting_recent_count, setting_rotation_step,
|
||||
@@ -192,6 +192,22 @@ class DocumentManyDeleteView(MultipleInstanceActionMixin, DeletedDocumentDeleteV
|
||||
model = DeletedDocument
|
||||
|
||||
|
||||
class EmptyTrashCanView(ConfirmView):
|
||||
extra_context = {
|
||||
'title': _('Empty trash can?')
|
||||
}
|
||||
view_permission = permission_empty_trash
|
||||
action_cancel_redirect = post_action_redirect = reverse_lazy('documents:document_list_deleted')
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
for deleted_document in DeletedDocument.objects.all():
|
||||
deleted_document.delete()
|
||||
|
||||
messages.success(request, _('Trash can emptied successfully'))
|
||||
|
||||
return HttpResponseRedirect(self.get_success_url())
|
||||
|
||||
|
||||
def document_properties(request, document_id):
|
||||
document = get_object_or_404(Document, pk=document_id)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user