Merge "Show 'Tenant name' column for non-admin users"
This commit is contained in:
commit
feeb14f8b8
@ -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
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user