Merge "Show 'Tenant name' column for non-admin users"

This commit is contained in:
Jenkins 2015-09-17 11:04:04 +00:00 committed by Gerrit Code Review
commit feeb14f8b8
2 changed files with 7 additions and 12 deletions

View File

@ -230,15 +230,3 @@ class PackageDefinitionsTable(tables.DataTable):
ToggleEnabled,
TogglePublicEnabled,
DeletePackage)
def get_columns(self):
"""Hides tenant name column for a regular user.
Since there are no enough rights to get this information.
"""
columns = super(PackageDefinitionsTable, self).get_columns()
if not self.request.user.is_superuser:
for i, column in enumerate(columns):
if column.name == 'tenant_name':
columns[i].classes.append('hide')
return columns

View File

@ -131,6 +131,13 @@ class PackageDefinitionsView(horizon_tables.DataTableView):
tenent_name_by_id = {tenant.id: tenant.name for tenant in tenants}
for i, p in enumerate(packages):
packages[i].tenant_name = tenent_name_by_id.get(p.owner_id)
else:
current_tenant = self.request.session['token'].tenant
for i, package in enumerate(packages):
if package.owner_id == current_tenant['id']:
packages[i].tenant_name = current_tenant['name']
else:
packages[i].tenant_name = 'other'
return packages
def get_context_data(self, **kwargs):