aboutsummaryrefslogtreecommitdiff
path: root/gn3/auth/authorisation/groups.py
blob: 5290196d3297ec2df0b9de18beb32cf1c2ac6255 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
"""Handle the management of resource/user groups."""
import uuid

from gn3.auth import db
from . import authorised_p

@authorised_p(
    ("create-group",), success_message="Successfully created group.",
    error_message="Failed to create group.")
def create_group(conn, group_name):
    """Create a group"""
    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