aboutsummaryrefslogtreecommitdiff
path: root/gn_auth/auth/authorisation/users
diff options
context:
space:
mode:
authorMunyoki Kilyungi2024-03-11 23:58:35 +0300
committerMunyoki Kilyungi2024-03-13 10:25:27 +0300
commit7e11ddbbdd6ddfa28367c02d0a3a7f3932c369ae (patch)
treea3f50b605411594ddf970752ffcb24a73f1d306b /gn_auth/auth/authorisation/users
parenta295d21a42a6ae9c463f7661b32df7de11095835 (diff)
downloadgn-auth-7e11ddbbdd6ddfa28367c02d0a3a7f3932c369ae.tar.gz
Define Group using a frozen dataclass.
* gn_auth/auth/authorisation/data/genotypes.py: Import dataclasses.asdict. (link_genotype_data): Replace dictify with asdict. * gn_auth/auth/authorisation/data/mrna.py: Import dataclasses.asdict. (link_mrna_data): Replace dictify with asdict. * gn_auth/auth/authorisation/data/phenotypes.py: Import dataclasses.asdict. (link_phenotype_data): Replace dictify with asdict. * gn_auth/auth/authorisation/resources/groups/models.py: Import dataclass. (Group): Use frozen dataclass. (Group.dictify): Delete. (GroupRole.dictify): Replace dictify with asdict. * gn_auth/auth/authorisation/resources/groups/views.py: Import dataclasses.asdict. Remove dictify import. (list_groups): Replace dictify with asdict. (create_group): Ditto. * gn_auth/auth/authorisation/resources/views.py: (resource_users): Replace dictify with asdict. * gn_auth/auth/authorisation/users/views.py: Import dataclasses.asdict. Remove dictify import. (user_details): Replace dictify with asdict. (user_group): Ditto. Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
Diffstat (limited to 'gn_auth/auth/authorisation/users')
-rw-r--r--gn_auth/auth/authorisation/users/views.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/gn_auth/auth/authorisation/users/views.py b/gn_auth/auth/authorisation/users/views.py
index 9e6c0c3..ae3c45e 100644
--- a/gn_auth/auth/authorisation/users/views.py
+++ b/gn_auth/auth/authorisation/users/views.py
@@ -2,13 +2,12 @@
import traceback
from typing import Any
from functools import partial
-
+from dataclasses import asdict
import sqlite3
from email_validator import validate_email, EmailNotValidError
from flask import request, jsonify, Response, Blueprint, current_app
from gn_auth.auth.db import sqlite3 as db
-from gn_auth.auth.dictify import dictify
from gn_auth.auth.db.sqlite3 import with_db_connection
from gn_auth.auth.authorisation.resources.models import (
@@ -48,7 +47,7 @@ def user_details() -> Response:
False, lambda grp: grp)# type: ignore[arg-type]
return jsonify({
**user_dets,
- "group": dictify(the_group) if the_group else False
+ "group": asdict(the_group) if the_group else False
})
@users.route("/roles", methods=["GET"])
@@ -134,7 +133,7 @@ def user_group() -> Response:
False, lambda grp: grp)# type: ignore[arg-type]
if group:
- return jsonify(dictify(group))
+ return jsonify(asdict(group))
raise NotFoundError("User is not a member of any group.")
@users.route("/resources", methods=["GET"])