aboutsummaryrefslogtreecommitdiff
path: root/gn_auth
diff options
context:
space:
mode:
Diffstat (limited to 'gn_auth')
-rw-r--r--gn_auth/auth/authorisation/resources/views.py33
1 files changed, 18 insertions, 15 deletions
diff --git a/gn_auth/auth/authorisation/resources/views.py b/gn_auth/auth/authorisation/resources/views.py
index 3a61704..24b2416 100644
--- a/gn_auth/auth/authorisation/resources/views.py
+++ b/gn_auth/auth/authorisation/resources/views.py
@@ -341,26 +341,29 @@ def toggle_public(resource_id: uuid.UUID) -> Response:
else "Made resource private")})
+def __resultset_to_roles__(roles, row):
+ """Convert SQLite3 resultset into `Role` objects"""
+ _role = roles.get(row["role_id"])
+ return {
+ **roles,
+ row["role_id"]: Role(
+ role_id=uuid.UUID(row["role_id"]),
+ role_name=row["role_name"],
+ user_editable=bool(row["user_editable"]),
+ privileges=(
+ (_role.privileges if bool(_role) else tuple()) +
+ (Privilege(
+ privilege_id=row["privilege_id"],
+ privilege_description=row[
+ "privilege_description"]),)))
+ }
+
+
@resources.route("<uuid:resource_id>/roles", methods=["GET"])
@require_oauth("profile group resource role")
def resource_roles(resource_id: uuid.UUID) -> Response:
"""Return the roles the user has to act on a given resource."""
with require_oauth.acquire("profile group resource role") as _token:
- def __resultset_to_roles__(roles, row):
- _role = roles.get(row["role_id"])
- return {
- **roles,
- row["role_id"]: Role(
- role_id=uuid.UUID(row["role_id"]),
- role_name=row["role_name"],
- user_editable=bool(row["user_editable"]),
- privileges=(
- (_role.privileges if bool(_role) else tuple()) +
- (Privilege(
- privilege_id=row["privilege_id"],
- privilege_description=row[
- "privilege_description"]),)))
- }
def __roles__(conn: db.DbConnection) -> tuple[Role, ...]: