diff --git a/apps/common/templates/generic_list.html b/apps/common/templates/generic_list.html index 1000e8f420..778d9764b5 100644 --- a/apps/common/templates/generic_list.html +++ b/apps/common/templates/generic_list.html @@ -70,6 +70,7 @@ {% with subtemplate.main_object as main_object %} {% with subtemplate.hide_link as hide_link %} {% with subtemplate.hide_header as hide_header %} + {% with subtemplate.multi_select as multi_select %} {% include subtemplate.name %} {% endwith %} {% endwith %} @@ -78,6 +79,7 @@ {% endwith %} {% endwith %} {% endwith %} + {% endwith %} {% endfor %} {% endblock %} diff --git a/apps/common/templates/generic_list_subtemplate.html b/apps/common/templates/generic_list_subtemplate.html index 47fc6dbb3f..c11ebf9045 100644 --- a/apps/common/templates/generic_list_subtemplate.html +++ b/apps/common/templates/generic_list_subtemplate.html @@ -30,6 +30,9 @@ {% if not hide_header %} + {% if multi_select %} + + {% endif %} {% if not hide_object %} {% trans "Identifier" %} {% endif %} @@ -46,6 +49,9 @@ {% endif %} {% for object in object_list %} + {% if multi_select %} + + {% endif %} {% if not hide_object %} {% if main_object %} {% with object|object_property:main_object as object %} diff --git a/apps/documents/urls.py b/apps/documents/urls.py index 867dd91a42..62ea103d1b 100644 --- a/apps/documents/urls.py +++ b/apps/documents/urls.py @@ -34,6 +34,7 @@ urlpatterns = patterns('documents.views', url(r'^document/(?P\d+)/create/siblings/$', 'document_create_sibling', {'multiple':True if ENABLE_SINGLE_DOCUMENT_UPLOAD == False else False}, 'document_create_sibling'), url(r'^document/(?P\d+)/find_duplicates/$', 'document_find_duplicates', (), 'document_find_duplicates'), url(r'^document/(?P\d+)/clear_transformations/$', 'document_clear_transformations', (), 'document_clear_transformations'), + url(r'^document/(?P[0-9,]+)/clear_transformations/$', 'document_clear_transformations', (), 'document_clear_transformations'), url(r'^duplicates/$', 'document_find_all_duplicates', (), 'document_find_all_duplicates'), url(r'^staging_file/(?P\w+)/preview/$', 'staging_file_preview', (), 'staging_file_preview'), diff --git a/apps/documents/views.py b/apps/documents/views.py index 4022ca4fe3..e1874cf418 100644 --- a/apps/documents/views.py +++ b/apps/documents/views.py @@ -74,6 +74,7 @@ def document_list(request): template_name='generic_list.html', extra_context={ 'title':_(u'documents'), + 'multi_select':True, }, ) @@ -734,29 +735,49 @@ def document_find_all_duplicates(request): return _find_duplicate_list(request, include_source=True) -def document_clear_transformations(request, document_id): +def document_clear_transformations(request, document_id=None, document_id_list=None): check_permissions(request.user, 'documents', [PERMISSION_DOCUMENT_TRANSFORM]) - previous = request.POST.get('previous', request.GET.get('previous', request.META.get('HTTP_REFERER', None))) - - document = get_object_or_404(Document, pk=document_id) + if document_id: + documents = [get_object_or_404(Document, pk=document_id)] + post_redirect = reverse('document_view', args=[documents[0].pk]) + elif document_id_list: + documents = [get_object_or_404(Document, pk=document_id) for document_id in document_id_list.split(',')] + post_redirect = None + + previous = request.POST.get('previous', request.GET.get('previous', request.META.get('HTTP_REFERER', post_redirect or reverse('document_list')))) + next = request.POST.get('next', request.GET.get('next', request.META.get('HTTP_REFERER', post_redirect or reverse('document_list')))) if request.method == 'POST': - for document_page in document.documentpage_set.all(): - for transformation in document_page.documentpagetransformation_set.all(): - transformation.delete() - - messages.success(request, _(u'All the page transformations for document: %s, have been deleted successfully.') % document) - return HttpResponseRedirect(reverse('document_view', args=[document.pk])) - + for document in documents: + for document_page in document.documentpage_set.all(): + for transformation in document_page.documentpagetransformation_set.all(): + transformation.delete() - return render_to_response('generic_confirm.html', { + if len(documents) == 1: + messages.success(request, _(u'All the page transformations for document: %s, have been deleted successfully.') % documents) + elif len(documents) > 1: + messages.success(request, _(u'All the page transformations for the documents: %s, have been deleted successfully.') % documents) + + return HttpResponseRedirect(next)#reverse('document_view', args=[document.pk])) + + context = { 'object_name':_(u'document transformation'), 'delete_view':True, - 'object':document, - 'title':_(u'Are you sure you with to clear all the page transformations for document: %s?') % document, + #'object':document, 'previous':previous, - }, context_instance=RequestContext(request)) + 'next':next, + } + + if len(documents) == 1: + context['object'] = documents[0] + context['title'] = _(u'Are you sure you with to clear all the page transformations for document: %s?') % ', '.join([unicode(d) for d in documents]) + elif len(documents) > 1: + context['title'] = _(u'Are you sure you with to clear all the page transformations for documents: %s?') % ', '.join([unicode(d) for d in documents]) + + + return render_to_response('generic_confirm.html', context, + context_instance=RequestContext(request)) def document_view_simple(request, document_id):