diff options
author | Munyoki Kilyungi | 2024-03-11 23:58:35 +0300 |
---|---|---|
committer | Munyoki Kilyungi | 2024-03-13 10:25:27 +0300 |
commit | 7e11ddbbdd6ddfa28367c02d0a3a7f3932c369ae (patch) | |
tree | a3f50b605411594ddf970752ffcb24a73f1d306b /gn_auth/auth/authorisation/resources/groups/views.py | |
parent | a295d21a42a6ae9c463f7661b32df7de11095835 (diff) | |
download | gn-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/resources/groups/views.py')
-rw-r--r-- | gn_auth/auth/authorisation/resources/groups/views.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/gn_auth/auth/authorisation/resources/groups/views.py b/gn_auth/auth/authorisation/resources/groups/views.py index 26534fc..b655a0f 100644 --- a/gn_auth/auth/authorisation/resources/groups/views.py +++ b/gn_auth/auth/authorisation/resources/groups/views.py @@ -6,13 +6,13 @@ import datetime from typing import Iterable from functools import partial +from dataclasses import asdict from MySQLdb.cursors import DictCursor from flask import request, jsonify, Response, Blueprint, current_app from gn_auth.auth.db import sqlite3 as db from gn_auth.auth.db import mariadb as gn3db from gn_auth.auth.db.sqlite3 import with_db_connection -from gn_auth.auth.dictify import dictify from gn_auth.auth.authorisation.roles.models import Role from gn_auth.auth.authorisation.roles.models import user_roles @@ -42,7 +42,7 @@ def list_groups(): the_groups = all_groups(conn) return jsonify(the_groups.maybe( - [], lambda grps: [dictify(grp) for grp in grps])) + [], lambda grps: [asdict(grp) for grp in grps])) @groups.route("/create", methods=["POST"]) @require_oauth("profile group") @@ -59,7 +59,7 @@ def create_group(): new_group = _create_group( conn, group_name, user, request.form.get("group_description")) return jsonify({ - **dictify(new_group), "group_leader": asdict(user) + **asdict(new_group), "group_leader": asdict(user) }) @groups.route("/members/<uuid:group_id>", methods=["GET"]) |