From f788d00ad05ad8f3703b81356df1e31e32e0cb3a Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Thu, 9 Feb 2023 16:25:51 +0300 Subject: oauth2: groups: Reject join requests. Add handler for rejecting user join requests. Fix a number of minor UI bugs. --- wqflask/wqflask/oauth2/groups.py | 16 ++++++++++++++++ .../wqflask/templates/oauth2/group_join_or_create.html | 2 +- wqflask/wqflask/templates/oauth2/join-requests.html | 3 ++- wqflask/wqflask/templates/oauth2/register_user.html | 2 +- wqflask/wqflask/templates/oauth2/view-user.html | 2 +- 5 files changed, 21 insertions(+), 4 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/oauth2/groups.py b/wqflask/wqflask/oauth2/groups.py index ee4e490b..f9e9bffe 100644 --- a/wqflask/wqflask/oauth2/groups.py +++ b/wqflask/wqflask/oauth2/groups.py @@ -115,3 +115,19 @@ def accept_join_request(): data=request.form).either( handle_error("oauth2.group.list_join_requests"), __success__) + +@groups.route("/reject-join-requests", methods=["POST"]) +@require_oauth2 +def reject_join_request(): + def __fail__(error): + err=process_error() + flash(f"{err['error']}: {err['error_description']}", "alert-danger") + return redirect(url_for("oauth2.group.list_join_requests")) + def __success__(requests): + flash("Request was rejected successfully.", "alert-success") + return redirect(url_for("oauth2.group.list_join_requests")) + return oauth2_post( + "oauth2/group/requests/join/reject", + data=request.form).either( + handle_error("oauth2.group.list_join_requests"), + __success__) diff --git a/wqflask/wqflask/templates/oauth2/group_join_or_create.html b/wqflask/wqflask/templates/oauth2/group_join_or_create.html index f3abc4ec..95696710 100644 --- a/wqflask/wqflask/templates/oauth2/group_join_or_create.html +++ b/wqflask/wqflask/templates/oauth2/group_join_or_create.html @@ -10,7 +10,7 @@ {{flash_me()}} - {%if group_join_request is defined %} + {%if group_join_request is defined and group_join_request.exists %}
diff --git a/wqflask/wqflask/templates/oauth2/join-requests.html b/wqflask/wqflask/templates/oauth2/join-requests.html index 996caf2e..0a05eec1 100644 --- a/wqflask/wqflask/templates/oauth2/join-requests.html +++ b/wqflask/wqflask/templates/oauth2/join-requests.html @@ -43,7 +43,8 @@