aboutsummaryrefslogtreecommitdiff
path: root/gn_auth/auth/authorisation/resources/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'gn_auth/auth/authorisation/resources/models.py')
-rw-r--r--gn_auth/auth/authorisation/resources/models.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/gn_auth/auth/authorisation/resources/models.py b/gn_auth/auth/authorisation/resources/models.py
index 93a1aff..783bf8a 100644
--- a/gn_auth/auth/authorisation/resources/models.py
+++ b/gn_auth/auth/authorisation/resources/models.py
@@ -384,7 +384,7 @@ def save_resource(
raise AuthorisationError(
"You do not have the appropriate privileges to edit this resource.")
-def resource_group(conn: db.DbConnection, resource: Resource) -> Maybe[Group]:
+def resource_group(conn: db.DbConnection, resource: Resource) -> Group:
"""Return the group that owns the resource."""
with db.cursor(conn) as cursor:
cursor.execute(
@@ -394,9 +394,9 @@ def resource_group(conn: db.DbConnection, resource: Resource) -> Maybe[Group]:
(str(resource.resource_id),))
row = cursor.fetchone()
if row:
- return Just(Group(
+ return Group(
UUID(row["group_id"]),
row["group_name"],
- json.loads(row["group_metadata"])))
+ json.loads(row["group_metadata"]))
- return Nothing
+ raise MissingGroupError("Resource has no 'owning' group.")