From 4d8dbeb6932c6485c49469a450f2591477239cbe Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 30 Jan 2023 14:37:54 +0300 Subject: oauth2: Add placeholder endpoints and UI elements Add some endpoints and UI elements to act as placeholders for yet to be implemented functionality. --- wqflask/wqflask/oauth2/groups.py | 17 ++++++++++++++ wqflask/wqflask/oauth2/resources.py | 30 +++++++++++++++++++++++++ wqflask/wqflask/templates/oauth2/group.html | 23 ++++++++++++++++++- wqflask/wqflask/templates/oauth2/resources.html | 10 ++++++--- 4 files changed, 76 insertions(+), 4 deletions(-) diff --git a/wqflask/wqflask/oauth2/groups.py b/wqflask/wqflask/oauth2/groups.py index 0bd40044..d04509df 100644 --- a/wqflask/wqflask/oauth2/groups.py +++ b/wqflask/wqflask/oauth2/groups.py @@ -37,3 +37,20 @@ def group_join_or_create(): groups = oauth2_get("oauth2/groups").either( lambda x: __raise_unimplemented__(), lambda x: x) return render_template("oauth2/group_join_or_create.html", groups=groups) + +@groups.route("/delete/", methods=["GET", "POST"]) +@require_oauth2 +def delete_group(group_id): + """Delete the user's group.""" + return "WOULD DELETE GROUP." + +@groups.route("/edit/", methods=["GET", "POST"]) +@require_oauth2 +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/oauth2/resources.py b/wqflask/wqflask/oauth2/resources.py index db5e1cc4..578e0414 100644 --- a/wqflask/wqflask/oauth2/resources.py +++ b/wqflask/wqflask/oauth2/resources.py @@ -1,3 +1,5 @@ +import uuid + from flask import Blueprint, render_template from .client import oauth2_get @@ -9,8 +11,36 @@ resources = Blueprint("resource", __name__) @resources.route("/", methods=["GET"]) @require_oauth2 def user_resources(): + """List the resources the user has access to.""" def __success__(resources): return render_template("oauth2/resources.html", resources=resources) return oauth2_get("oauth2/user-resources").either( __request_error__, __success__) + +@resources.route("/create", methods=["GET"]) +@require_oauth2 +def create_resource(): + """Create a new resource.""" + return "WOULD CREATE A NEW RESOURCE." + +@resources.route("/view/", methods=["GET"]) +@require_oauth2 +def view_resource(resource_id: uuid.UUID): + """View the given resource.""" + # Display the resource's details + # Provide edit/delete options + # Metadata edit maybe? + return "WOULD DISPLAY THE GIVEN RESOURCE'S DETAILS" + +@resources.route("/edit/", methods=["GET"]) +@require_oauth2 +def edit_resource(resource_id: uuid.UUID): + """Edit the given resource.""" + return "WOULD Edit THE GIVEN RESOURCE'S DETAILS" + +@resources.route("/delete/", methods=["GET"]) +@require_oauth2 +def delete_resource(resource_id: uuid.UUID): + """Delete the given resource.""" + return "WOULD DELETE THE GIVEN RESOURCE" diff --git a/wqflask/wqflask/templates/oauth2/group.html b/wqflask/wqflask/templates/oauth2/group.html index df69a573..1475b10d 100644 --- a/wqflask/wqflask/templates/oauth2/group.html +++ b/wqflask/wqflask/templates/oauth2/group.html @@ -3,7 +3,7 @@ {%block title%}View User{%endblock%} {%block content%}
- {{profile_nav("dashboard")}} + {{profile_nav("group")}}

User's Group

{{flash_me()}} @@ -21,6 +21,27 @@
+
+
+ + +
+ +
+ + +
+
+ + {%if group%} + + {%endif%} + diff --git a/wqflask/wqflask/templates/oauth2/resources.html b/wqflask/wqflask/templates/oauth2/resources.html index 38f851e6..44774fda 100644 --- a/wqflask/wqflask/templates/oauth2/resources.html +++ b/wqflask/wqflask/templates/oauth2/resources.html @@ -8,13 +8,17 @@ {{flash_me()}} - {{resources}} -
+
{%for resource in resources %} - {{role}} + {{resource.resource_name}} - {{resource.resource_category}} - {{resource.group}} {%else%}

  -- cgit v1.2.3