aboutsummaryrefslogtreecommitdiff
path: root/gn2
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-06-11 11:33:56 -0500
committerFrederick Muriuki Muriithi2024-06-11 11:35:07 -0500
commit8f82e6348a531dc17cff12a3fb8b401d99ff4138 (patch)
treeafb63acf21d2423768c8c02d8867bbafb73c70ef /gn2
parentcb1ac070c5400907c326e8657160eb8e6c1c9b98 (diff)
downloadgenenetwork2-8f82e6348a531dc17cff12a3fb8b401d99ff4138.tar.gz
List user assigned role of interest.
Diffstat (limited to 'gn2')
-rw-r--r--gn2/wqflask/oauth2/resources.py16
-rw-r--r--gn2/wqflask/templates/oauth2/view-resource-role.html32
2 files changed, 47 insertions, 1 deletions
diff --git a/gn2/wqflask/oauth2/resources.py b/gn2/wqflask/oauth2/resources.py
index 9ca057ab..58e02368 100644
--- a/gn2/wqflask/oauth2/resources.py
+++ b/gn2/wqflask/oauth2/resources.py
@@ -308,11 +308,25 @@ def view_resource_role(resource_id: UUID, role_id: UUID):
def __render_template__(**kwargs):
return render_ui("oauth2/view-resource-role.html", **kwargs)
+ def __fetch_users__(resource, role, unassigned_privileges):
+ return oauth2_get(
+ f"auth/resource/{resource_id}/role/{role_id}/users").either(
+ lambda error: __render_template__(
+ resource=resource,
+ role=role,
+ unassigned_privileges=unassigned_privileges,
+ user_error=process_error(error)),
+ lambda users: __render_template__(
+ resource=resource,
+ role=role,
+ unassigned_privileges=unassigned_privileges,
+ users=users))
+
def __fetch_all_roles__(resource, role):
return oauth2_get(f"auth/resource/{resource_id}/roles").either(
lambda error: __render_template__(
all_roles_error=process_error(error)),
- lambda all_roles: __render_template__(
+ lambda all_roles: __fetch_users__(
resource=resource,
role=role,
unassigned_privileges=[
diff --git a/gn2/wqflask/templates/oauth2/view-resource-role.html b/gn2/wqflask/templates/oauth2/view-resource-role.html
index c4c9d3fc..57008f44 100644
--- a/gn2/wqflask/templates/oauth2/view-resource-role.html
+++ b/gn2/wqflask/templates/oauth2/view-resource-role.html
@@ -98,6 +98,38 @@
</form>
</div>
+ {%if user_error is defined%}
+ {{display_error("Users", user_error)}}
+ {%endif%}
+
+ {%if users is defined and users | length > 0%}
+ <div class="row">
+ <h3>Users</h3>
+
+ <table class="table">
+ <caption>
+ Users assigned role '{{role.role_name}}' on resource
+ '{{resource.resource_name}}'
+ </caption>
+
+ <thead>
+ <tr>
+ <th>Email</th>
+ <th>Name</th>
+ </tr>
+ </thead>
+
+ <tbody>
+ {%for user in users%}
+ <tr>
+ <td>{{user.email}}</td>
+ <td>{{user.name}}</td>
+ </tr>
+ {%endfor%}
+ </tbody>
+ </table>
+ </div>
+ {%endif%}
&nbsp;
</p>
{%endif%}