diff --git a/apps/common/templates/generic_list_subtemplate.html b/apps/common/templates/generic_list_subtemplate.html index 8a317bb7ca..d1494312bf 100644 --- a/apps/common/templates/generic_list_subtemplate.html +++ b/apps/common/templates/generic_list_subtemplate.html @@ -5,6 +5,7 @@ {% load non_breakable %} {% load variable_tags %} {% load main_settings_tags %} +{% load multiselect_tags %} {% get_main_setting "DISABLE_ICONS" as disable_icons %} @@ -91,7 +92,13 @@ {% for object in object_list %} {% if multi_select or multi_select_as_buttons %} - + + {% if multi_select_item_properties %} + + {% else %} + + {% endif %} + {% endif %} {% if not hide_object %} {% if main_object %} diff --git a/apps/common/templatetags/multiselect_tags.py b/apps/common/templatetags/multiselect_tags.py new file mode 100644 index 0000000000..27801f0d93 --- /dev/null +++ b/apps/common/templatetags/multiselect_tags.py @@ -0,0 +1,14 @@ +from django.template import Library +from django.utils.simplejson import dumps + +from common.utils import return_attrib + +register = Library() + + +@register.filter +def get_encoded_parameter(item, parameters_dict): + result = {} + for attrib_name, attrib in parameters_dict.items(): + result[attrib_name] = return_attrib(item, attrib) + return dumps(result) diff --git a/apps/common/views.py b/apps/common/views.py index 48c2570bb5..8575e3b788 100644 --- a/apps/common/views.py +++ b/apps/common/views.py @@ -8,6 +8,7 @@ from django.contrib.contenttypes.models import ContentType from django.core.urlresolvers import reverse from django.utils.http import urlencode from django.contrib.auth.views import login +from django.utils.simplejson import dumps, loads from common.forms import ChoiceForm, UserForm, UserForm_view, \ ChangelogForm, LicenseForm @@ -34,19 +35,28 @@ def multi_object_action_view(request): action = request.GET.get('action', None) id_list = u','.join([key[3:] for key in request.GET.keys() if key.startswith('pk_')]) + items_property_list = [loads(key[11:]) for key in request.GET.keys() if key.startswith('properties_')] if not action: messages.error(request, _(u'No action selected.')) return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/')) - if not id_list: + if not id_list and not items_property_list: messages.error(request, _(u'Must select at least one item.')) return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/')) - return HttpResponseRedirect('%s?%s' % ( - action, - urlencode({'id_list': id_list, 'next': next})) - ) + # Separate redirects to keep backwards compatibility with older + # functions that don't expect a properties_list parameter + if items_property_list: + return HttpResponseRedirect('%s?%s' % ( + action, + urlencode({'items_property_list': dumps(items_property_list), 'next': next})) + ) + else: + return HttpResponseRedirect('%s?%s' % ( + action, + urlencode({'id_list': id_list, 'next': next})) + ) def get_obj_from_content_type_string(string):