Display members' count of environment roles

This commit is contained in:
richard-dds 2018-09-24 14:45:03 -04:00 committed by Andrew Croce
parent 5fec89d120
commit ac1c4cd5b7
2 changed files with 13 additions and 5 deletions

View File

@ -41,8 +41,8 @@ class WorkspaceUser(object):
return "active"
@property
def has_environment_roles(self):
num_environment_roles = (
def num_environment_roles(self):
return (
db.session.query(EnvironmentRole)
.join(EnvironmentRole.environment)
.join(Environment.project)
@ -51,4 +51,7 @@ class WorkspaceUser(object):
.filter(EnvironmentRole.user_id == self.user_id)
.count()
)
return num_environment_roles > 0
@property
def has_environment_roles(self):
return self.num_environment_roles > 0

View File

@ -82,16 +82,21 @@
<thead>
<tr>
<th scope="col" width="50%">Name</th>
<th scope="col" class='table-cell--shrink'>&nbsp;<span class="hide">Status Flag</span></th>
<th scope="col">Environments</th>
<th scope="col">Status</th>
<th scope="col">Workspace Role</th>
</tr>
</thead>
<tbody>
{% for m in workspace.members %}
{% set num_environment_roles = m.num_environment_roles %}
<tr>
<td><a href="{{ url_for('workspaces.update_member', workspace_id=workspace.id, member_id=m.user_id) }}" class="icon-link icon-link--large">{{ m.user_name }}</a></td>
<td class='table-cell--shrink'>{% if not m.has_environment_roles %} <span class="label label--info">No Environment Access</span> {% endif %}</td>
{% if num_environment_roles %}
<td class="table-cell--align-right">{{ num_environment_roles }}</td>
{% else %}
<td class='table-cell--shrink'><span class="label label--info">No Environment Access</span></td>
{% endif %}
<td>{{ m.status }}</a></td>
<td>{{ m.role }}</a></td>
</tr>