diff options
-rw-r--r-- | gn_auth/auth/authorisation/resources/groups/models.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/gn_auth/auth/authorisation/resources/groups/models.py b/gn_auth/auth/authorisation/resources/groups/models.py index 597ac37..a1937ce 100644 --- a/gn_auth/auth/authorisation/resources/groups/models.py +++ b/gn_auth/auth/authorisation/resources/groups/models.py @@ -690,10 +690,16 @@ def delete_group(conn: db.DbConnection, group_id: UUID): sqlite3.IntegrityError: if the group has members or linked resources, or both. """ + rsc = group_resource(conn, group_id) with db.cursor(conn) as cursor: cursor.execute("DELETE FROM group_join_requests WHERE group_id=?", (str(group_id),)) - cursor.execute("DELETE FROM group_resources WHERE group_id=?", - (str(group_id),)) + cursor.execute("DELETE FROM user_roles WHERE resource_id=?", + (str(rsc.resource_id),)) + cursor.execute( + "DELETE FROM group_resources WHERE group_id=? AND resource_id=?", + (str(group_id), str(rsc.resource_id))) + cursor.execute("DELETE FROM resources WHERE resource_id=?", + (str(rsc.resource_id),)) cursor.execute("DELETE FROM groups WHERE group_id=?", (str(group_id),)) |