1
0
forked from ScoDoc/ScoDoc

API: ajout /partition/<int:partition_id>/remove_etudiant/<int:etudid>

This commit is contained in:
Emmanuel Viennet 2022-07-23 15:29:12 +02:00
parent 02fee61aa5
commit 1aaee35d64

View File

@ -150,6 +150,24 @@ def set_etud_group(etudid: int, group_id: int):
return jsonify({"group_id": group_id, "etudid": etudid})
@bp.route(
"/partition/<int:partition_id>/remove_etudiant/<int:etudid>", 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/<int:partition_id>/group/create", methods=["POST"])
@permission_required_api(Permission.ScoEtudChangeGroups, Permission.APIEditGroups)
def group_create(partition_id: int):