aboutsummaryrefslogtreecommitdiff
path: root/gn3/auth/authorisation/groups.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-11-14 18:04:08 +0300
committerFrederick Muriuki Muriithi2022-11-14 18:04:08 +0300
commit6b964b95a67bac69a1217b3f9c39c58a19881df4 (patch)
treef83ac08fa06c7535c1fcb3926876029e2ec17a52 /gn3/auth/authorisation/groups.py
parentbaf7980cd6080c8cb4e6c6b585948144273600aa (diff)
downloadgenenetwork3-6b964b95a67bac69a1217b3f9c39c58a19881df4.tar.gz
auth: Implement `create_group`
Diffstat (limited to 'gn3/auth/authorisation/groups.py')
-rw-r--r--gn3/auth/authorisation/groups.py15
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