From 3b142f08f55d71fd3df6307420f46b1c0ba2bddb Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Tue, 31 Jan 2023 14:12:41 +0300 Subject: oauth2: Display members in groups page. Rework UI. --- wqflask/wqflask/oauth2/groups.py | 22 ++++-- wqflask/wqflask/templates/oauth2/group.html | 103 ++++++++++++++++++++-------- 2 files changed, 92 insertions(+), 33 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/oauth2/groups.py b/wqflask/wqflask/oauth2/groups.py index eab0049c..e04f6ef8 100644 --- a/wqflask/wqflask/oauth2/groups.py +++ b/wqflask/wqflask/oauth2/groups.py @@ -10,8 +10,23 @@ groups = Blueprint("group", __name__) @groups.route("/", methods=["GET"]) def user_group(): + """Get the user's group.""" + def __process_error__(error): + if error.status_code == 404: + return { + "error": "NotFoundError", + "error_message": ("Requested endpoint was not found on the " + "API server.") + } + return error.json() + def __success__(group): - return render_template("oauth2/group.html", group=group) + return oauth2_get(f"oauth2/group-users/{group['group_id']}").either( + lambda error: render_template( + "oauth2/group.html", group=group, + user_error=__process_error__(error)), + lambda users: render_template( + "oauth2/group.html", group=group, users=users)) return oauth2_get("oauth2/user-group").either( request_error, __success__) @@ -51,8 +66,3 @@ def delete_group(group_id): def edit_group(group_id): """Edit the user's group.""" return "WOULD EDIT GROUP." - -@groups.route("//users/list", methods=["GET", "POST"]) -@require_oauth2 -def list_group_users(group_id): - return "WOULD LIST GROUP USERS." diff --git a/wqflask/wqflask/templates/oauth2/group.html b/wqflask/wqflask/templates/oauth2/group.html index 1475b10d..8db5b0d9 100644 --- a/wqflask/wqflask/templates/oauth2/group.html +++ b/wqflask/wqflask/templates/oauth2/group.html @@ -4,43 +4,92 @@ {%block content%}
{{profile_nav("group")}} -

User's Group

{{flash_me()}}
-
+ + + + + + + + + -
Name
{{group.group_name}}
+ + + + + + + + - {%for key,value in group.group_metadata.items()%} -
{{key.split("_") | map('capitalize') | join(" ")}}
-
{{value}}
- {%endfor%} - - + {%for key,val in group.group_metadata.items()%} + + + + + {%endfor%} -
-
- - - - -
- - - +
+
Group Information
NameMetadataActions
+ {{group.group_name}} + KeyValue + Edit + + Delete +
{{key.split("_") | map("capitalize") | join(" ")}}{{val}}
+
- {%if group%} - - {%endif%} +
+ + + + + + + + + + + + + {%for user in users%} + + + + + + {%else%} + + + + {%endfor%} + +
Group Users
NameEmailActions
{{user.name}}{{user.email}} + Remove +
+ {%if user_error is defined%} + + +   + {{user_error.error}} + {{user_error.error_message}} + {%else%} + No users found for this group + {%endif%} +
-- cgit v1.2.3