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
This commit is contained in:
Ryan Peters 2016-08-23 16:27:26 -05:00
parent e7b4bdfe5d
commit a988f3c457

View File

@ -906,6 +906,24 @@ class DataTableOptions(object):
String containing the template which should be used to render the String containing the template which should be used to render the
table. Defaults to ``"horizon/common/_data_table.html"``. 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 .. attribute:: context_var_name
The name of the context variable which will contain the table when The name of the context variable which will contain the table when
@ -1031,12 +1049,18 @@ class DataTableOptions(object):
self.template = getattr(options, self.template = getattr(options,
'template', 'template',
'horizon/common/_data_table.html') 'horizon/common/_data_table.html')
self.row_actions_dropdown_template = ('horizon/common/_data_table_' self.row_actions_dropdown_template = \
'row_actions_dropdown.html') getattr(options,
self.row_actions_row_template = ('horizon/common/_data_table_' 'row_actions_dropdown_template',
'row_actions_row.html') '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 = \ 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, self.context_var_name = six.text_type(getattr(options,
'context_var_name', 'context_var_name',
'table')) 'table'))