aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-02-09 14:01:14 +0300
committerFrederick Muriuki Muriithi2023-02-09 14:01:14 +0300
commitbcc845d44bac5866f021320cf15f0d0b2ca341c0 (patch)
tree12ef6737240774b9010e7a779849c025d651bdf0
parentda84304778e2df6835f46bae4b7cd9f97ecf52b2 (diff)
downloadgenenetwork2-bcc845d44bac5866f021320cf15f0d0b2ca341c0.tar.gz
oauth2: Remove create/join options with active request
If a user has an active join request, then do not provide them with the option to create a new group, or even to request to join another group.
-rw-r--r--wqflask/wqflask/oauth2/groups.py20
-rw-r--r--wqflask/wqflask/templates/oauth2/group_join_or_create.html13
-rw-r--r--wqflask/wqflask/templates/oauth2/view-user.html9
3 files changed, 39 insertions, 3 deletions
diff --git a/wqflask/wqflask/oauth2/groups.py b/wqflask/wqflask/oauth2/groups.py
index b49cb550..ee4e490b 100644
--- a/wqflask/wqflask/oauth2/groups.py
+++ b/wqflask/wqflask/oauth2/groups.py
@@ -54,9 +54,23 @@ def join_or_create():
if bool(usr_dets["group"]):
flash("You are already a member of a group.", "alert-info")
return redirect(url_for("oauth2.user.user_profile"))
- groups = oauth2_get("oauth2/group/list").either(
- lambda x: raise_unimplemented(), lambda x: x)
- return render_template("oauth2/group_join_or_create.html", groups=groups)
+ def __group_error__(err):
+ return render_template(
+ "oauth2/group_join_or_create.html", groups=[],
+ groups_error=process_error(err))
+ def __group_success__(groups):
+ return oauth2_get("oauth2/user/group/join-request").either(
+ __gjr_error__, partial(__gjr_success__, groups=groups))
+ def __gjr_error__(err):
+ return render_template(
+ "oauth2/group_join_or_create.html", groups=[],
+ gjr_error=process_error(err))
+ def __gjr_success__(gjr, groups):
+ return render_template(
+ "oauth2/group_join_or_create.html", groups=groups,
+ group_join_request=gjr)
+ return oauth2_get("oauth2/group/list").either(
+ __group_error__, __group_success__)
@groups.route("/delete/<uuid:group_id>", methods=["GET", "POST"])
@require_oauth2
diff --git a/wqflask/wqflask/templates/oauth2/group_join_or_create.html b/wqflask/wqflask/templates/oauth2/group_join_or_create.html
index 73f7a5de..f3abc4ec 100644
--- a/wqflask/wqflask/templates/oauth2/group_join_or_create.html
+++ b/wqflask/wqflask/templates/oauth2/group_join_or_create.html
@@ -10,6 +10,18 @@
{{flash_me()}}
+ {%if group_join_request is defined %}
+ <p>
+ <span class="glyphicon glyphicon-info-sign text-warning"></span>
+ &nbsp;
+ <span class="text-info">You have an active request to join a group.</span>
+ </p>
+
+ <p class="explainer">
+ You cannot create a group, or request to join a new group until your
+ currently active request has been either accepted or rejected.
+ </p>
+ {%else%}
<p>You can</p>
{%if groups | length > 0 %}
@@ -79,5 +91,6 @@
<input type="submit" value="Create Group" class="btn btn-primary" />
</div>
</form>
+ {%endif%}
</div>
{%endblock%}
diff --git a/wqflask/wqflask/templates/oauth2/view-user.html b/wqflask/wqflask/templates/oauth2/view-user.html
index 72821108..7360e4d2 100644
--- a/wqflask/wqflask/templates/oauth2/view-user.html
+++ b/wqflask/wqflask/templates/oauth2/view-user.html
@@ -22,12 +22,21 @@
<span class="text-warning">User is not a member of a group.</span>
</p>
+ {%if group_join_request is defined %}
+ <p>
+ <span class="glyphicon glyphicon-info-sign text-warning"></span>
+ &nbsp;
+ <span class="text-info">You have an active join request to a group.</span>
+ </p>
+ {%else%}
<p><a href="{{url_for('oauth2.group.join_or_create')}}"
class="btn btn-primary"
title="Join an existing group, or create your own group">
Join or Create group
</a></p>
{%endif%}
+
+ {%endif%}
{%else%}
<p class="text-warning">No details found.</p>
{%endif%}