From e97623e1587355c9bc97266c586d20b35a0c3f74 Mon Sep 17 00:00:00 2001 From: wangliangyu Date: Thu, 14 Dec 2017 17:05:12 +0800 Subject: [PATCH] table: Show checkbox only when there is BatchAction Checkbox in a table assumes BatchAction. This commit checks whether at least one BatchAction is included as table actions and displays checkboxes only when BatchAction is available. Change-Id: Ia1cba6c59f5d40f7df7f4b98a9f459a6934cfbb7 Closes-Bug: #1744742 --- horizon/tables/base.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/horizon/tables/base.py b/horizon/tables/base.py index 955dcd313c..bff0cd4afa 100644 --- a/horizon/tables/base.py +++ b/horizon/tables/base.py @@ -41,6 +41,7 @@ from horizon import conf from horizon import exceptions from horizon.forms import ThemableCheckboxInput from horizon import messages +from horizon.tables.actions import BatchAction from horizon.tables.actions import FilterAction from horizon.tables.actions import LinkAction from horizon.utils import html @@ -1548,6 +1549,8 @@ class DataTable(object): template_path = self._meta.table_actions_template table_actions_template = template.loader.get_template(template_path) bound_actions = self.get_table_actions() + batch_actions = [action for action in bound_actions + if isinstance(action, BatchAction)] extra_context = {"table_actions": bound_actions, "table_actions_buttons": [], "table_actions_menu": []} @@ -1562,7 +1565,7 @@ class DataTable(object): if self._meta.table_actions_menu_label: extra_context['table_actions_menu_label'] = \ self._meta.table_actions_menu_label - self.set_multiselect_column_visibility(len(bound_actions) > 0) + self.set_multiselect_column_visibility(len(batch_actions) > 0) return table_actions_template.render(extra_context, self.request) def render_row_actions(self, datum, row=False):