diff --git a/apps/common/templates/generic_list_subtemplate.html b/apps/common/templates/generic_list_subtemplate.html index d1494312bf..15732c8998 100644 --- a/apps/common/templates/generic_list_subtemplate.html +++ b/apps/common/templates/generic_list_subtemplate.html @@ -6,6 +6,7 @@ {% load variable_tags %} {% load main_settings_tags %} {% load multiselect_tags %} +{% load subtemplates_tags %} {% get_main_setting "DISABLE_ICONS" as disable_icons %} @@ -76,7 +77,9 @@ {{ column.name|capfirst }} {% endfor %} - {% for column in object_list.0|get_model_list_columns %} + {% get_object_list_object_name object_list.0 %} + + {% for column in object|get_model_list_columns %} {{ column.name|capfirst }} {% endfor %} @@ -89,15 +92,17 @@ {% endif %} {% endif %} + {% for object in object_list %} + {% get_object_list_object_name object %} {% if multi_select or multi_select_as_buttons %} - {% if multi_select_item_properties %} - - {% else %} - - {% endif %} + {% if multi_select_item_properties %} + + {% else %} + + {% endif %} {% endif %} {% if not hide_object %} diff --git a/apps/common/templatetags/subtemplates_tags.py b/apps/common/templatetags/subtemplates_tags.py index d759df4bbb..228c5ce8af 100644 --- a/apps/common/templatetags/subtemplates_tags.py +++ b/apps/common/templatetags/subtemplates_tags.py @@ -1,9 +1,11 @@ import re -from django.template import Node, TemplateSyntaxError, Library, \ - Variable, Context +from django.template import (Node, TemplateSyntaxError, Library, + Variable, Context) from django.template.loader import get_template +from common.utils import return_attrib + register = Library() @@ -49,3 +51,15 @@ def render_subtemplate(parser, token): return RenderSubtemplateNode(template_name, template_context, var_name) #format_string[1:-1] + + +@register.simple_tag(takes_context=True) +def get_object_list_object_name(context, source_object): + object_list_object_name = context.get('object_list_object_name') + if object_list_object_name: + context['object'] = return_attrib(source_object, object_list_object_name) + else: + context['object'] = source_object + + return '' +