From edc3b79d34995ad98914ad556e10eaa377774eb3 Mon Sep 17 00:00:00 2001 From: Anusha Ramineni Date: Mon, 24 Jul 2017 15:25:24 +0530 Subject: [PATCH] Atomic rules to be displayed in UI This commit enables atomic rules table rows to be displayed in UI Change-Id: I8859815339193a190863429c877555d9a2d205d7 Closes-Bug:#1705677 --- congress_dashboard/datasources/views.py | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/congress_dashboard/datasources/views.py b/congress_dashboard/datasources/views.py index dd58cca..4f6b201 100644 --- a/congress_dashboard/datasources/views.py +++ b/congress_dashboard/datasources/views.py @@ -172,6 +172,7 @@ class DetailView(tables.DataTableView): column_names = [] table_class_attrs = copy.deepcopy(dict(self.table_class.__dict__)) # Get schema from the server. + schema = {} try: if is_service: schema = congress.datasource_table_schema_get( @@ -180,22 +181,15 @@ class DetailView(tables.DataTableView): schema = congress.policy_table_schema_get( self.request, datasource_id, table_name) except Exception as e: - msg_args = { - 'table_name': table_name, - 'ds_id': datasource_id, - 'error': str(e) - } - msg = _('Unable to get schema for table "%(table_name)s", ' - 'data source "%(ds_id)s": %(error)s') % msg_args - messages.error(self.request, msg) - redirect = reverse('horizon:admin:datasources:index') - raise exceptions.Http302(redirect) + # Unable to get the schema, might be atomic rule, just display + # without column names ... + schema['columns'] = [] - columns = schema['columns'] row_len = 0 if len(rows): row_len = len(rows[0].get('data', [])) + columns = schema['columns'] if not row_len or row_len == len(columns): for col in columns: col_name = col['name'] @@ -246,7 +240,6 @@ class DetailView(tables.DataTableView): messages.error(self.request, msg) redirect = reverse('horizon:admin:datasources:index') raise exceptions.Http302(redirect) - return rows def get_context_data(self, **kwargs):