diff options
author | Munyoki Kilyungi | 2024-03-11 19:34:18 +0300 |
---|---|---|
committer | Munyoki Kilyungi | 2024-03-13 10:13:27 +0300 |
commit | 27d40788e2e2c8fbeb8873e895d77a76bbd49a45 (patch) | |
tree | 06fdcd39670332c743e590c85f8a99211f834205 /gn_auth/auth/authorisation/resources/models.py | |
parent | b6970d21dd0f8e132f8625c09f8aa595350b0218 (diff) | |
download | gn-auth-27d40788e2e2c8fbeb8873e895d77a76bbd49a45.tar.gz |
Define User using a frozen dataclass.
* gn_auth/auth/authentication/users.py: Import dataclass. Remove
NamedTuple and Tuple import.
(User): Use a frozen dataclass.
(User.get_user_id): Delete.
(User.dictify): Ditto.
* gn_auth/auth/authorisation/data/views.py: Import dataclasses.dict.
(authorisation): Replace user._asdict() with asdict(user).
(metadata_resources): Ditto.
* gn_auth/auth/authorisation/resources/groups/views.py:
(group_members): Replace dictify with asdict.
* gn_auth/auth/authorisation/resources/models.py: Import
dataclasses.asdict.
(assign_resource_user): Replace dictify(user) with asdict(user).
(unassign_resource_user): Ditto.
* gn_auth/auth/authorisation/resources/views.py:
(resource_users): Replace dictify with asdict.
* gn_auth/auth/authorisation/users/masquerade/views.py: Import
dataclasses.asdict.
(masquerade): Replace masq_user._asdict() with asdict(masq_user).
* gn_auth/auth/authorisation/users/views.py:
(list_all_users): 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.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/gn_auth/auth/authorisation/resources/models.py b/gn_auth/auth/authorisation/resources/models.py index 3693ad1..7ebf5f7 100644 --- a/gn_auth/auth/authorisation/resources/models.py +++ b/gn_auth/auth/authorisation/resources/models.py @@ -1,4 +1,5 @@ """Handle the management of resources.""" +from dataclasses import asdict from uuid import UUID, uuid4 from functools import reduce, partial from sqlite3 import Row @@ -341,7 +342,7 @@ def assign_resource_user( str(resource.resource_id))) return { "resource": dictify(resource), - "user": dictify(user), + "user": asdict(user), "role": dictify(role), "description": ( f"The user '{user.name}'({user.email}) was assigned the " @@ -365,7 +366,7 @@ def unassign_resource_user( str(resource.resource_id))) return { "resource": dictify(resource), - "user": dictify(user), + "user": asdict(user), "role": dictify(role), "description": ( f"The user '{user.name}'({user.email}) had the " |