From 1aaee35d6478621b29c63cc1d7cc13e354d2d110 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sat, 23 Jul 2022 15:29:12 +0200 Subject: [PATCH] API: ajout /partition//remove_etudiant/ --- app/api/partitions.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/api/partitions.py b/app/api/partitions.py index 8305c7543..f1092a7ab 100644 --- a/app/api/partitions.py +++ b/app/api/partitions.py @@ -150,6 +150,24 @@ def set_etud_group(etudid: int, group_id: int): return jsonify({"group_id": group_id, "etudid": etudid}) +@bp.route( + "/partition//remove_etudiant/", methods=["POST"] +) +@permission_required_api(Permission.ScoEtudChangeGroups, Permission.APIEditGroups) +def partition_remove_etud(partition_id: int, etudid: int): + """ """ + etud = Identite.query.get_or_404(etudid) + groups = ( + GroupDescr.query.filter_by(partition_id=partition_id) + .join(group_membership) + .filter_by(etudid=etudid) + ) + for g in groups: + g.etuds.remove(etud) + db.session.commit() + return jsonify({"partition_id": partition_id, "etudid": etudid}) + + @bp.route("/partition//group/create", methods=["POST"]) @permission_required_api(Permission.ScoEtudChangeGroups, Permission.APIEditGroups) def group_create(partition_id: int):