From 9fbfa3861d1c294df0d39c2b7bca84be81aed7a9 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Tue, 10 Oct 2023 22:52:00 +0200 Subject: [PATCH] =?UTF-8?q?Fix:=20creation=20assiduite=20via=20API=20non?= =?UTF-8?q?=20d=C3=A9partementale?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/assiduites.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/api/assiduites.py b/app/api/assiduites.py index 1b8eec7aa..23c9e2fd2 100644 --- a/app/api/assiduites.py +++ b/app/api/assiduites.py @@ -11,7 +11,7 @@ from flask import g, request from flask_json import as_json from flask_login import current_user, login_required -from app import db, log +from app import db, log, set_sco_dept import app.scodoc.sco_assiduites as scass import app.scodoc.sco_utils as scu from app.api import api_bp as bp @@ -474,13 +474,14 @@ def assiduite_create(etudid: int = None, nip=None, ine=None): """ etud: Identite = tools.get_etud(etudid, nip, ine) - if etud is None: return json_error( 404, message="étudiant inconnu", ) - + if not hasattr(g, "scodoc_dept_id") and etud.dept_id is not None: + # route sans département + set_sco_dept(etud.departement.acronym) create_list: list[object] = request.get_json(force=True) if not isinstance(create_list, list): @@ -533,7 +534,6 @@ def assiduites_create(): """ create_list: list[object] = request.get_json(force=True) - if not isinstance(create_list, list): return json_error(404, "Le contenu envoyé n'est pas une liste") @@ -544,6 +544,9 @@ def assiduites_create(): if etud is None: errors.append({"indice": i, "message": "Cet étudiant n'existe pas."}) continue + if not hasattr(g, "scodoc_dept_id") and etud.dept_id is not None: + # route sans département + set_sco_dept(etud.departement.acronym) code, obj = _create_singular(data, etud) if code == 404: