def render_table_actions(self):
"""Renders the actions specified in ``Meta.table_actions``."""
template_path = self._meta.table_actions_template
table_actions_template = template.loader.get_template(template_path)
bound_actions = self.get_table_actions()
extra_context = {"table_actions": bound_actions,
"table_actions_buttons": [],
"table_actions_menu": []}
if self._meta.filter and (
self._filter_action(self._meta._filter_action, self.request)):
extra_context["filter"] = self._meta._filter_action
for action in bound_actions:
if action.__class__ in self._meta.table_actions_menu:
extra_context['table_actions_menu'].append(action)
elif action != extra_context.get('filter'):
extra_context['table_actions_buttons'].append(action)
context = template.RequestContext(self.request, extra_context)
self.set_multiselect_column_visibility(len(bound_actions) > 0)
return table_actions_template.render(context)
评论列表
文章目录