aboutsummaryrefslogtreecommitdiff
path: root/gn_auth/auth/authorisation/resources/models.py
diff options
context:
space:
mode:
authorMunyoki Kilyungi2024-03-12 00:59:07 +0300
committerMunyoki Kilyungi2024-03-13 15:34:56 +0300
commit1c3d0fc73dfe4682ff41a2c8bd84a29f2d2b130a (patch)
treeb019fe88388eae409354234292c1f053bbdb1b71 /gn_auth/auth/authorisation/resources/models.py
parent58fde0def491099d3833e3d58ec7c441d84d1ef2 (diff)
downloadgn-auth-1c3d0fc73dfe4682ff41a2c8bd84a29f2d2b130a.tar.gz
Define Resource/ResourceCategory using frozen dataclass.
* gn_auth/auth/authorisation/resources/base.py: Import dataclass and asdict. Remove NamedTuple and dictify. (ResourceCategory): Use frozen dataclass. (ResourceCategory.dictify): Delete. (Resource): Use frozen dataclass. (Resource.dictify): Delete. * gn_auth/auth/authorisation/resources/models.py: Delete dictify import. (assign_resource_user): Replace dictify with asdict. (unassign_resource_user): Ditto. * gn_auth/auth/authorisation/resources/views.py: Import asdict. Remove dictify import. (list_resource_categories): Replace dictify with asdict. (create_resource): Ditto. (view_resource): Ditto. (__safe_get_requests_page__): Ditto. * gn_auth/auth/authorisation/users/views.py: (user_resources): Replace dictify with asdict. Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
Diffstat (limited to 'gn_auth/auth/authorisation/resources/models.py')
-rw-r--r--gn_auth/auth/authorisation/resources/models.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/gn_auth/auth/authorisation/resources/models.py b/gn_auth/auth/authorisation/resources/models.py
index 97e6adf..3720baa 100644
--- a/gn_auth/auth/authorisation/resources/models.py
+++ b/gn_auth/auth/authorisation/resources/models.py
@@ -6,7 +6,6 @@ from sqlite3 import Row
from typing import Dict, Sequence, Optional
from gn_auth.auth.db import sqlite3 as db
-from gn_auth.auth.dictify import dictify
from gn_auth.auth.authentication.users import User
from gn_auth.auth.db.sqlite3 import with_db_connection
@@ -341,7 +340,7 @@ def assign_resource_user(
(str(user.user_id), str(role.role.role_id),
str(resource.resource_id)))
return {
- "resource": dictify(resource),
+ "resource": asdict(resource),
"user": asdict(user),
"role": asdict(role),
"description": (
@@ -365,7 +364,7 @@ def unassign_resource_user(
str(role.role.role_id),
str(resource.resource_id)))
return {
- "resource": dictify(resource),
+ "resource": asdict(resource),
"user": asdict(user),
"role": asdict(role),
"description": (