diff --git a/apps/common/api.py b/apps/common/api.py index 78df9d5bb4..4637f3a0fa 100644 --- a/apps/common/api.py +++ b/apps/common/api.py @@ -4,9 +4,15 @@ from django.db.utils import DatabaseError object_navigation = {} +multi_object_navigation = {} menu_links = [] model_list_columns = {} + + +def register_multi_item_links(src, links, menu_name=None): + pass + def register_links(src, links, menu_name=None): if menu_name in object_navigation: if hasattr(src, '__iter__'): diff --git a/apps/common/forms.py b/apps/common/forms.py index 295270ea49..9834f18b3c 100644 --- a/apps/common/forms.py +++ b/apps/common/forms.py @@ -6,6 +6,10 @@ from django.conf import settings from common.utils import return_attrib + + +class MultiItemForm(forms.Form): + action = forms.ChoiceField() class DetailSelectMultiple(forms.widgets.SelectMultiple): diff --git a/apps/common/templates/generic_list_subtemplate.html b/apps/common/templates/generic_list_subtemplate.html index c11ebf9045..438156a1df 100644 --- a/apps/common/templates/generic_list_subtemplate.html +++ b/apps/common/templates/generic_list_subtemplate.html @@ -25,7 +25,7 @@
{% endif %} -
+ {% if not hide_header %} @@ -50,7 +50,7 @@ {% for object in object_list %} {% if multi_select %} - + {% endif %} {% if not hide_object %} {% if main_object %} @@ -86,7 +86,10 @@ {% endfor %}
- {% paginate %} + {% if multi_select %} + {% get_multi_item_links_form %} + {% endif %} + {% paginate %}
diff --git a/apps/common/templatetags/navigation.py b/apps/common/templatetags/navigation.py index b8f2689615..0a1fcafae5 100644 --- a/apps/common/templatetags/navigation.py +++ b/apps/common/templatetags/navigation.py @@ -7,8 +7,10 @@ from django.core.urlresolvers import RegexURLResolver, RegexURLPattern, Resolver from django.template import TemplateSyntaxError, Library, \ VariableDoesNotExist, Node, Variable from django.utils.text import unescape_string_literal +from django.utils.translation import ugettext as _ from common.api import object_navigation, menu_links as menu_navigation +from common.forms import MultiItemForm register = Library() @@ -234,3 +236,12 @@ def object_navigation_template(context): return new_context register.inclusion_tag('generic_navigation.html', takes_context=True)(object_navigation_template) + +def get_multi_item_links_form(context): + new_context = copy.copy(context) + new_context.update({ + 'form':MultiItemForm(), + 'title':_(u'Selected item actions:') + }) + return new_context +register.inclusion_tag('generic_form_subtemplate.html', takes_context=True)(get_multi_item_links_form) diff --git a/apps/documents/__init__.py b/apps/documents/__init__.py index c887a5636b..20002ddfab 100644 --- a/apps/documents/__init__.py +++ b/apps/documents/__init__.py @@ -4,7 +4,7 @@ from django.utils.translation import ugettext_lazy as _ from django.core.urlresolvers import reverse from common.api import register_links, register_menu, \ - register_model_list_columns + register_model_list_columns, register_multi_item_links from common.utils import pretty_size from permissions.api import register_permissions @@ -62,6 +62,7 @@ staging_file_delete = {'text':_('delete'), 'view':'staging_file_delete', 'args': register_links(Document, [document_view_simple, document_view, document_edit, document_edit_metadata, document_delete, document_download, document_find_duplicates, document_clear_transformations], menu_name='sidebar') register_links(Document, [document_list, document_create, document_create_multiple, document_create_sibling], menu_name='sidebar') +register_multi_item_links(Document, [document_clear_transformations], menu_name='sidebar') if ENABLE_SINGLE_DOCUMENT_UPLOAD: register_links(['document_list', 'document_create', 'document_create_multiple', 'upload_document_with_type', 'upload_multiple_documents_with_type'], [document_list, document_create, document_create_multiple], menu_name='sidebar') diff --git a/apps/documents/views.py b/apps/documents/views.py index e1874cf418..9de30e184a 100644 --- a/apps/documents/views.py +++ b/apps/documents/views.py @@ -754,7 +754,7 @@ def document_clear_transformations(request, document_id=None, document_id_list=N for transformation in document_page.documentpagetransformation_set.all(): transformation.delete() - if len(documents) == 1: + 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)