Merge "Atomic rules to be displayed in UI"

This commit is contained in:
Jenkins 2017-07-27 04:52:42 +00:00 committed by Gerrit Code Review
commit 491c96dfaa
1 changed files with 5 additions and 12 deletions

View File

@ -171,6 +171,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(
@ -179,22 +180,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']
@ -245,7 +239,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):