diff options
author | Frederick Muriuki Muriithi | 2022-11-14 18:04:08 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2022-11-14 18:04:08 +0300 |
commit | 6b964b95a67bac69a1217b3f9c39c58a19881df4 (patch) | |
tree | f83ac08fa06c7535c1fcb3926876029e2ec17a52 /gn3/auth/authorisation/groups.py | |
parent | baf7980cd6080c8cb4e6c6b585948144273600aa (diff) | |
download | genenetwork3-6b964b95a67bac69a1217b3f9c39c58a19881df4.tar.gz |
auth: Implement `create_group`
Diffstat (limited to 'gn3/auth/authorisation/groups.py')
-rw-r--r-- | gn3/auth/authorisation/groups.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/gn3/auth/authorisation/groups.py b/gn3/auth/authorisation/groups.py index 8c8a87f..ad30763 100644 --- a/gn3/auth/authorisation/groups.py +++ b/gn3/auth/authorisation/groups.py @@ -1,7 +1,16 @@ """Handle the management of resource/user groups.""" +import uuid +from gn3.auth import db from . import authorised_p -@authorised_p -def create_group(group_name): - raise Exception("NOT IMPLEMENTED!") +@authorised_p( + ("create-group",), success_message="Successfully created group.", + error_message="Failed to create group.") +def create_group(conn, group_name): + with db.cursor(conn) as cursor: + group_id = uuid.uuid4() + cursor.execute( + "INSERT INTO groups(group_id, group_name) VALUES (?, ?)", + (str(group_id), group_name)) + return group_id |