diff --git a/horizon/tables/base.py b/horizon/tables/base.py index bb029f8948..2c2f08fb5c 100644 --- a/horizon/tables/base.py +++ b/horizon/tables/base.py @@ -943,6 +943,11 @@ class DataTableOptions(object): Boolean to control whether or not to show the table's footer. Default: ``True``. + .. attribute:: hidden_title + + Boolean to control whether or not to show the table's title. + Default: ``True``. + .. attribute:: permissions A list of permission names which this table requires in order to be @@ -968,6 +973,7 @@ class DataTableOptions(object): self.pagination_param = getattr(options, 'pagination_param', 'marker') self.browser_table = getattr(options, 'browser_table', None) self.footer = getattr(options, 'footer', True) + self.hidden_title = getattr(options, 'hidden_title', True) self.no_data_message = getattr(options, "no_data_message", _("No items to display.")) @@ -1253,7 +1259,8 @@ class DataTable(object): def render(self): """Renders the table using the template from the table options.""" table_template = template.loader.get_template(self._meta.template) - extra_context = {self._meta.context_var_name: self} + extra_context = {self._meta.context_var_name: self, + 'hidden_title': self._meta.hidden_title} context = template.RequestContext(self.request, extra_context) return table_template.render(context) diff --git a/horizon/templates/horizon/common/_data_table.html b/horizon/templates/horizon/common/_data_table.html index c7d2cf0a89..75630fa7ee 100644 --- a/horizon/templates/horizon/common/_data_table.html +++ b/horizon/templates/horizon/common/_data_table.html @@ -9,7 +9,9 @@ {% block table_caption %} -

{{ table }}

+ {% if not hidden_title %} +

{{ table }}

+ {% endif %} {{ table.render_table_actions }} diff --git a/horizon/test/tests/tables.py b/horizon/test/tests/tables.py index 93712c4609..7ba4517b17 100644 --- a/horizon/test/tests/tables.py +++ b/horizon/test/tests/tables.py @@ -581,12 +581,19 @@ class DataTableTests(test.TestCase): update_string = "action=row_update&table=my_table&obj_id=" self.assertContains(resp, update_string, 3) self.assertContains(resp, "data-update-interval", 3) + # Verify no table heading + self.assertNotContains(resp, "

' '<strong>evil</strong>', 1) + # Hidden Title = False shows the table title + self.table._meta.hidden_title = False + resp = http.HttpResponse(self.table.render()) + self.assertContains(resp, "