diff options
author | Frederick Muriuki Muriithi | 2023-09-14 12:06:23 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2023-09-26 03:44:30 +0300 |
commit | e19b01571ce61e01f482a1dadeeb2fd835fda939 (patch) | |
tree | 27b8c7f86313a86bc1e6705ac65ff5996403eace /gn_auth/auth/authorisation/resources/views.py | |
parent | 345e33fc8e1b12dda6626307ebac7e1206200974 (diff) | |
download | gn-auth-e19b01571ce61e01f482a1dadeeb2fd835fda939.tar.gz |
Move `groups` package under `resources` package
With user groups being resources that users can act on (with the
recent changes), this commit moves the `groups` module to under the
`resources` module.
It also renames the `*_resources.py` modules by dropping the
`_resources` part since the code is under the `resources` module
anyway.
Diffstat (limited to 'gn_auth/auth/authorisation/resources/views.py')
-rw-r--r-- | gn_auth/auth/authorisation/resources/views.py | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/gn_auth/auth/authorisation/resources/views.py b/gn_auth/auth/authorisation/resources/views.py index 4fe04d9..0e44df5 100644 --- a/gn_auth/auth/authorisation/resources/views.py +++ b/gn_auth/auth/authorisation/resources/views.py @@ -6,23 +6,23 @@ from functools import reduce from flask import request, jsonify, Response, Blueprint, current_app as app -from ...db import sqlite3 as db -from ...db.sqlite3 import with_db_connection +from gn_auth.auth.db import sqlite3 as db +from gn_auth.auth.db.sqlite3 import with_db_connection + +from gn_auth.auth.authorisation.roles import Role +from gn_auth.auth.authorisation.errors import InvalidData, InconsistencyError, AuthorisationError + +from gn_auth.auth.dictify import dictify +from gn_auth.auth.authentication.oauth2.resource_server import require_oauth +from gn_auth.auth.authentication.users import User, user_by_id, user_by_email from .checks import authorised_for from .models import ( - Resource, save_resource, resource_data, resource_group, resource_by_id, + Resource, save_resource, resource_data, resource_by_id, resource_categories, assign_resource_user, link_data_to_resource, unassign_resource_user, resource_category_by_id, unlink_data_from_resource, create_resource as _create_resource) - -from ..roles import Role -from ..errors import InvalidData, InconsistencyError, AuthorisationError -from ..groups.models import Group, GroupRole, group_role_by_id - -from ...dictify import dictify -from ...authentication.oauth2.resource_server import require_oauth -from ...authentication.users import User, user_by_id, user_by_email +from .groups.models import Group, GroupRole, resource_owner, group_role_by_id resources = Blueprint("resources", __name__) @@ -165,7 +165,7 @@ def resource_users(resource_id: uuid.UUID): "user", User(user_id, row["email"], row["name"])) role = GroupRole( uuid.UUID(row["group_role_id"]), - resource_group(conn, resource), + resource_owner(conn, resource), Role(uuid.UUID(row["role_id"]), row["role_name"], bool(int(row["user_editable"])), tuple())) return { @@ -222,7 +222,7 @@ def assign_role_to_user(resource_id: uuid.UUID) -> Response: return assign_resource_user( conn, resource, user, group_role_by_id(conn, - resource_group(conn, resource), + resource_owner(conn, resource), uuid.UUID(group_role_id))) except AssertionError as aserr: raise AuthorisationError(aserr.args[0]) from aserr @@ -246,7 +246,7 @@ def unassign_role_to_user(resource_id: uuid.UUID) -> Response: return unassign_resource_user( conn, resource, user_by_id(conn, uuid.UUID(user_id)), group_role_by_id(conn, - resource_group(conn, resource), + resource_owner(conn, resource), uuid.UUID(group_role_id))) except AssertionError as aserr: raise AuthorisationError(aserr.args[0]) from aserr |