aboutsummaryrefslogtreecommitdiff
path: root/gn3
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2021-11-15 07:10:45 +0300
committerFrederick Muriuki Muriithi2021-11-15 07:10:45 +0300
commit7d3929486142481ba0fe36f302845accf8b497ee (patch)
tree5e5a89ec8864811dda9d384293a67ef830e896fc /gn3
parent63b70daaffd2c3e095fde3ed59a07bb9ee894c4f (diff)
parentf566d9eb1d4e12d7e7a6ef319c39760f5726578e (diff)
downloadgenenetwork3-7d3929486142481ba0fe36f302845accf8b497ee.tar.gz
Merge branch 'main' of github.com:genenetwork/genenetwork3 into partial-correlations
Diffstat (limited to 'gn3')
-rw-r--r--gn3/authentication.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/gn3/authentication.py b/gn3/authentication.py
index 6719631..a6372c1 100644
--- a/gn3/authentication.py
+++ b/gn3/authentication.py
@@ -113,9 +113,9 @@ def get_groups_by_user_uid(user_uid: str, conn: Redis) -> Dict:
"""
admin = []
member = []
- for uuid, group_info in conn.hgetall("groups").items():
+ for group_uuid, group_info in conn.hgetall("groups").items():
group_info = json.loads(group_info)
- group_info["uuid"] = uuid
+ group_info["uuid"] = group_uuid
if user_uid in group_info.get('admins'):
admin.append(group_info)
if user_uid in group_info.get('members'):
@@ -130,11 +130,10 @@ def get_user_info_by_key(key: str, value: str,
conn: Redis) -> Optional[Dict]:
"""Given a key, get a user's information if value is matched"""
if key != "user_id":
- for uuid, user_info in conn.hgetall("users").items():
+ for user_uuid, user_info in conn.hgetall("users").items():
user_info = json.loads(user_info)
- if (key in user_info and
- user_info.get(key) == value):
- user_info["user_id"] = uuid
+ if (key in user_info and user_info.get(key) == value):
+ user_info["user_id"] = user_uuid
return user_info
elif key == "user_id":
if user_info := conn.hget("users", value):
@@ -145,9 +144,13 @@ def get_user_info_by_key(key: str, value: str,
def create_group(conn: Redis, group_name: Optional[str],
- admin_user_uids: List = [],
- member_user_uids: List = []) -> Optional[Dict]:
+ admin_user_uids: List = None,
+ member_user_uids: List = None) -> Optional[Dict]:
"""Create a group given the group name, members and admins of that group."""
+ if admin_user_uids is None:
+ admin_user_uids = []
+ if member_user_uids is None:
+ member_user_uids = []
if group_name and bool(admin_user_uids + member_user_uids):
timestamp = datetime.datetime.utcnow().strftime('%b %d %Y %I:%M%p')
group = {