From 18a6ada32ea8453a6ac939f20ef78b722d1b1b6c Mon Sep 17 00:00:00 2001 From: zsloan Date: Wed, 6 May 2020 10:22:09 -0500 Subject: Commiting a few minor changes plus returning rqtl_mapping.py to the same as on testing branch before merging Danny's changes and testing them --- wqflask/utility/redis_tools.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'wqflask/utility') diff --git a/wqflask/utility/redis_tools.py b/wqflask/utility/redis_tools.py index 0754e16f..573f9945 100644 --- a/wqflask/utility/redis_tools.py +++ b/wqflask/utility/redis_tools.py @@ -78,3 +78,21 @@ def check_verification_code(code): else: return None flash("Invalid code: Password reset code does not exist or might have expired!", "error") + +def get_user_groups(user_id): + #ZS: Get the groups where a user is an admin or a member and return lists corresponding to those two sets of groups + admin_group_ids = [] #ZS: Group IDs where user is an admin + user_group_ids = [] #ZS: Group IDs where user is a regular user + groups_list = Redis.hgetall("groups") + for key in groups_list: + group_ob = json.loads(groups_list[key]) + group_admins = set(group_ob['admins']) + group_users = set(group_ob['users']) + if user_id in group_admins: + admin_group_ids.append(group_ob['id']) + elif user_id in group_users: + user_group_ids.append(group_ob['id']) + else: + continue + + return admin_group_ids, user_group_ids -- cgit v1.2.3