diff options
author | Frederick Muriuki Muriithi | 2023-01-21 03:18:10 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2023-01-21 03:18:10 +0300 |
commit | 3d04f8a28386a08a19c01f8154872fcff4936dec (patch) | |
tree | d58999f53863067973eed72bcc2e07255fbd0130 /gn3/auth/authorisation/groups.py | |
parent | a95819958123282b5b961cf88afd8e5588acb666 (diff) | |
download | genenetwork3-3d04f8a28386a08a19c01f8154872fcff4936dec.tar.gz |
auth: Groups - Fetch all existing groups
Diffstat (limited to 'gn3/auth/authorisation/groups.py')
-rw-r--r-- | gn3/auth/authorisation/groups.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/gn3/auth/authorisation/groups.py b/gn3/auth/authorisation/groups.py index bbabd44..3367b57 100644 --- a/gn3/auth/authorisation/groups.py +++ b/gn3/auth/authorisation/groups.py @@ -145,3 +145,14 @@ def is_group_leader(cursor: db.DbCursor, user: User, group: Group): role_names = tuple(row[0] for row in cursor.fetchall()) return "group-leader" in role_names + +def all_groups(conn: db.DbConnection) -> Maybe[Sequence[Group]]: + """Retrieve all existing groups""" + with db.cursor(conn) as cursor: + cursor.execute("SELECT * FROM groups") + res = cursor.fetchall() + if res: + return Just(tuple( + Group(row["group_id"], row["group_name"]) for row in res)) + + return Nothing |