aboutsummaryrefslogtreecommitdiff
path: root/wqflask/utility
diff options
context:
space:
mode:
authorzsloan2020-05-06 10:22:09 -0500
committerzsloan2020-05-06 10:22:09 -0500
commit18a6ada32ea8453a6ac939f20ef78b722d1b1b6c (patch)
treefeab6c2409a20bd58104099acb5036b46d9205be /wqflask/utility
parenta1db50c2a09e9666b18aeada21785c86e715b865 (diff)
downloadgenenetwork2-18a6ada32ea8453a6ac939f20ef78b722d1b1b6c.tar.gz
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
Diffstat (limited to 'wqflask/utility')
-rw-r--r--wqflask/utility/redis_tools.py18
1 files changed, 18 insertions, 0 deletions
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