diff options
author | Alexander Kabui | 2024-08-30 16:47:55 +0300 |
---|---|---|
committer | GitHub | 2024-08-30 16:47:55 +0300 |
commit | ed20621c23a9a41152f3d6a48334f2a31c018033 (patch) | |
tree | 5e2182b99f5f05e2f667dfce1b762921c4ec62dc /gn2/wqflask/oauth2/ui.py | |
parent | 9a345d8abf2f0045b2c47bfcf1ae5860273452be (diff) | |
parent | 6db49002d4d2e69fcf4fdd6be6aceeea7b95664f (diff) | |
download | genenetwork2-ed20621c23a9a41152f3d6a48334f2a31c018033.tar.gz |
Merge pull request #861 from genenetwork/feature/gnqa-search-2
Feature/gnqa search 2
Diffstat (limited to 'gn2/wqflask/oauth2/ui.py')
-rw-r--r-- | gn2/wqflask/oauth2/ui.py | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/gn2/wqflask/oauth2/ui.py b/gn2/wqflask/oauth2/ui.py index cf2e9af7..04095420 100644 --- a/gn2/wqflask/oauth2/ui.py +++ b/gn2/wqflask/oauth2/ui.py @@ -1,22 +1,17 @@ """UI utilities""" -from flask import session, render_template +from flask import render_template from .client import oauth2_get -from .client import user_logged_in -from .request_utils import process_error def render_ui(templatepath: str, **kwargs): """Handle repetitive UI rendering stuff.""" - roles = kwargs.get("roles", tuple()) # Get roles if already provided - if user_logged_in() and not bool(roles): # If not, try fetching them - roles_results = oauth2_get("auth/system/roles").either( - lambda err: {"roles_error": process_error(err)}, - lambda roles: {"roles": roles}) - kwargs = {**kwargs, **roles_results} + roles = kwargs.get("roles", tuple()) # Get roles + if not roles: + roles = oauth2_get("auth/system/roles").either( + lambda _err: roles, lambda auth_roles: auth_roles) user_privileges = tuple( - privilege["privilege_id"] for role in roles - for privilege in role["privileges"]) + privilege["privilege_id"] for role in roles for privilege in role["privileges"]) kwargs = { - **kwargs, "roles": roles, "user_privileges": user_privileges + **kwargs, "roles": roles, "user_privileges": user_privileges, } return render_template(templatepath, **kwargs) |