From 429d07662258bb4a139fd22249e258caacddf78c Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 30 Jan 2023 03:01:57 +0300 Subject: oauth2: Display user's group information. --- wqflask/wqflask/oauth2/groups.py | 10 ++++++++- wqflask/wqflask/oauth2/users.py | 8 ------- wqflask/wqflask/templates/oauth2/group.html | 27 +++++++++++++++++++++++ wqflask/wqflask/templates/oauth2/profile_nav.html | 2 +- 4 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 wqflask/wqflask/templates/oauth2/group.html diff --git a/wqflask/wqflask/oauth2/groups.py b/wqflask/wqflask/oauth2/groups.py index 3dc6f00f..0bd40044 100644 --- a/wqflask/wqflask/oauth2/groups.py +++ b/wqflask/wqflask/oauth2/groups.py @@ -2,10 +2,18 @@ from flask import Blueprint, render_template from .checks import require_oauth2 from .client import oauth2_get, oauth2_post -from .request_utils import __user_details__ +from .request_utils import __user_details__, __request_error__ groups = Blueprint("group", __name__) +@groups.route("/", methods=["GET"]) +def user_group(): + def __success__(group): + return render_template("oauth2/group.html", group=group) + + return oauth2_get("oauth2/user-group").either( + __request_error__, __success__) + @groups.route("/create", methods=["POST"]) @require_oauth2 def create_group(): diff --git a/wqflask/wqflask/oauth2/users.py b/wqflask/wqflask/oauth2/users.py index 4db60434..bd958049 100644 --- a/wqflask/wqflask/oauth2/users.py +++ b/wqflask/wqflask/oauth2/users.py @@ -21,11 +21,3 @@ def user_profile(): @require_oauth2 def request_add_to_group(): return "WOULD SEND MESSAGE TO HAVE YOU ADDED TO GROUP..." - -@users.route("/group", methods=["GET"]) -def user_group(): - def __success__(group): - return render_template("oauth2/group.html", group=group) - - return oauth2_get("oauth2/user-group").either( - __request_error__, __success__) diff --git a/wqflask/wqflask/templates/oauth2/group.html b/wqflask/wqflask/templates/oauth2/group.html new file mode 100644 index 00000000..df69a573 --- /dev/null +++ b/wqflask/wqflask/templates/oauth2/group.html @@ -0,0 +1,27 @@ +{%extends "base.html"%} +{%from "oauth2/profile_nav.html" import profile_nav%} +{%block title%}View User{%endblock%} +{%block content%} +
+ {{profile_nav("dashboard")}} +

User's Group

+ + {{flash_me()}} + +
+
+
+ +
Name
{{group.group_name}}
+ + {%for key,value in group.group_metadata.items()%} +
{{key.split("_") | map('capitalize') | join(" ")}}
+
{{value}}
+ {%endfor%} +
+
+ +
+ +
+{%endblock%} diff --git a/wqflask/wqflask/templates/oauth2/profile_nav.html b/wqflask/wqflask/templates/oauth2/profile_nav.html index 1baf4924..5c69a17d 100644 --- a/wqflask/wqflask/templates/oauth2/profile_nav.html +++ b/wqflask/wqflask/templates/oauth2/profile_nav.html @@ -13,7 +13,7 @@ {%if calling_page == "group"%} class="active" {%endif%}> - Group + Group