Fix: creation assiduite via API non départementale

This commit is contained in:
Emmanuel Viennet 2023-10-10 22:52:00 +02:00
parent 579d71937d
commit 9fbfa3861d

View File

@ -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: