From a988f3c457fca8cd990eec507638cf0dcc0c5011 Mon Sep 17 00:00:00 2001 From: Ryan Peters Date: Tue, 23 Aug 2016 16:27:26 -0500 Subject: [PATCH] All Table Templates should support template overrides Overrides were not possible on some templates due to not reading from the "options" array while assigning values in the DataTableOptions class. Change-Id: Ia0905cbf772445c39006d10a5a040b5244587914 Closes-bug: #1616222 --- horizon/tables/base.py | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/horizon/tables/base.py b/horizon/tables/base.py index 14a5977dc2..444fa7c7c1 100644 --- a/horizon/tables/base.py +++ b/horizon/tables/base.py @@ -906,6 +906,24 @@ class DataTableOptions(object): String containing the template which should be used to render the table. Defaults to ``"horizon/common/_data_table.html"``. + .. attribute:: row_actions_dropdown_template + + String containing the template which should be used to render the + row actions dropdown. Defaults to + ``"horizon/common/_data_table_row_actions_dropdown.html"``. + + .. attribute:: row_actions_row_template + + String containing the template which should be used to render the + row actions. Defaults to + ``"horizon/common/_data_table_row_actions_row.html"``. + + .. attribute:: table_actions_template + + String containing the template which should be used to render the + table actions. Defaults to + ``"horizon/common/_data_table_table_actions.html"``. + .. attribute:: context_var_name The name of the context variable which will contain the table when @@ -1031,12 +1049,18 @@ class DataTableOptions(object): self.template = getattr(options, 'template', 'horizon/common/_data_table.html') - self.row_actions_dropdown_template = ('horizon/common/_data_table_' - 'row_actions_dropdown.html') - self.row_actions_row_template = ('horizon/common/_data_table_' - 'row_actions_row.html') + self.row_actions_dropdown_template = \ + getattr(options, + 'row_actions_dropdown_template', + 'horizon/common/_data_table_row_actions_dropdown.html') + self.row_actions_row_template = \ + getattr(options, + 'row_actions_row_template', + 'horizon/common/_data_table_row_actions_row.html') self.table_actions_template = \ - 'horizon/common/_data_table_table_actions.html' + getattr(options, + 'table_actions_template', + 'horizon/common/_data_table_table_actions.html') self.context_var_name = six.text_type(getattr(options, 'context_var_name', 'table'))