aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-01-20 11:56:52 +0300
committerFrederick Muriuki Muriithi2023-01-20 11:58:33 +0300
commitbb2d80af509c0697eebe5ced23de99345135dc6b (patch)
tree4b1bec4c240578a82e7ee13337655a79b492eba6
parent69d7d2e49c7381b9fb757bfcc6d83d59df6442b3 (diff)
downloadgenenetwork2-bb2d80af509c0697eebe5ced23de99345135dc6b.tar.gz
oauth2: Add user-profile template and dummy endpoints
* wqflask/wqflask/oauth2/routes.py: add some dummy endpoints to be fleshed out * wqflask/wqflask/templates/oauth2/view-user.html: Add missing template for the /user-profile endpoint
-rw-r--r--wqflask/wqflask/oauth2/routes.py10
-rw-r--r--wqflask/wqflask/templates/oauth2/view-user.html110
2 files changed, 120 insertions, 0 deletions
diff --git a/wqflask/wqflask/oauth2/routes.py b/wqflask/wqflask/oauth2/routes.py
index 4ab1f9c6..4ba94025 100644
--- a/wqflask/wqflask/oauth2/routes.py
+++ b/wqflask/wqflask/oauth2/routes.py
@@ -130,3 +130,13 @@ def user_profile():
return render_template(
"oauth2/view-user.html", user_details=user_details, roles=roles,
resources=resources)
+
+@oauth2.route("/request-add-to-group")
+@require_oauth2
+def request_add_to_group():
+ return "WOULD SEND MESSAGE TO HAVE YOU ADDED TO GROUP..."
+
+@oauth2.route("/create-group")
+@require_oauth2
+def create_group():
+ return "WOULD CREATE A NEW GROUP..."
diff --git a/wqflask/wqflask/templates/oauth2/view-user.html b/wqflask/wqflask/templates/oauth2/view-user.html
new file mode 100644
index 00000000..5415ba6e
--- /dev/null
+++ b/wqflask/wqflask/templates/oauth2/view-user.html
@@ -0,0 +1,110 @@
+{%extends "base.html"%}
+{%block title%}View User{%endblock%}
+{%block content%}
+<div class="container" style="min-width: 1250px;">
+ <h3>View User</h3>
+
+ <div class="container-fluid">
+ <div class="row">
+ <div class="panel panel-primary col-md-3">
+ <div class="panel-heading"><h3>User Details</h3></div>
+ <div class="panel-body">
+ {%if user_details%}
+ <p><strong>Name</strong>: {{user_details.name}}</p>
+ <p><strong>E-Mail</strong>: {{user_details.email}}</p>
+ {%if user_details.group%}
+ <p><strong>Group</strong>:{{user_details.group}}</p>
+ {%else%}
+ <p>
+ <span class="glyphicon glyphicon-warning-sign text-warning"></span>
+ &nbsp;
+ <span class="text-warning">User is not a member of a group.</span>
+ </p>
+
+ <p>You can</p>
+
+ <form action="{{url_for('oauth2.request_add_to_group')}}"
+ method="POST">
+ <legend>Request to be added to group</legend>
+ <div class="form-group">
+ <label class="control-label" for="group">Group</label>
+ <select class="form-control" id="group">
+ <option value="">Select a group</option>
+ {%for group in groups%}
+ <option value="{{group.group_id}}">{{group.group_name}}</option>
+ {%endfor%}
+ </select>
+ </div>
+ <div class="form-group">
+ <input type="submit" value="Request Access" class="btn btn-primary" />
+ </div>
+ </form>
+
+ <p>or</p>
+
+ <form action="{{url_for('oauth2.create_group')}}"
+ method="POST">
+ <legend>Create a new group</legend>
+ <div class="form-group">
+ <label class="control-label" for="group_name">Group Name</label>
+ <input type="text" class="form-control" id="group_name" name="group_name" />
+ </div>
+ <div class="form-group">
+ <input type="submit" value="Create Group" class="btn btn-primary" />
+ </div>
+ </form>
+ {%endif%}
+ {%else%}
+ <p class="text-warning">No details found.</p>
+ {%endif%}
+ </div>
+ <div class="panel-footer"></div>
+ </div>
+ </div>
+ </div>
+
+ <div class="container-fluid">
+ <div class="row">
+ <div class="panel panel-primary col-md-3">
+ <div class="panel-heading"><h3>Resources</h3></div>
+ <div class="panel-body">
+ <p>The user has access to the following resources:</p>
+ {%for resource in resources %}
+ {{role}}
+ {%else%}
+ <p>
+ <span class="glyphicon glyphicon-warning-sign"></span>&nbsp;
+ <span class="text-warning">
+ The user has no access to any resource.
+ </span>
+ </p>
+ {%endfor%}
+ </div>
+ <div class="panel-footer"></div>
+ </div>
+ </div>
+ </div>
+
+ <div class="container-fluid">
+ <div class="row">
+ <div class="panel panel-primary col-md-3">
+ <div class="panel-heading">
+ <h3>Other Roles</h3>
+ </div>
+ <div class="panel-body">
+ {%for role in roles %}
+ {{role}}
+ {%else%}
+ <p>
+ <span class="glyphicon glyphicon-warning-sign"></span>&nbsp;
+ <span class="text-warning">No roles attached to this user</span>
+ </p>
+ {%endfor%}
+ </div>
+ <div class="panel-footer"></div>
+ </div>
+ </div>
+ </div>
+
+</div>
+{%endblock%}