Bulletins: vérification plus stricte des arguments

This commit is contained in:
Emmanuel Viennet 2022-07-13 12:03:53 +02:00
parent 4921d45129
commit 9d72954cc1
2 changed files with 20 additions and 16 deletions

View File

@ -148,12 +148,15 @@ def formsemestre_bulletinetud_dict(formsemestre_id, etudid, version="long"):
I["server_name"] = request.url_root
# Formation et parcours
formation_dict = None
if I["sem"]["formation_id"]:
I["formation"] = sco_formations.formation_list(
formation_dicts = sco_formations.formation_list(
args={"formation_id": I["sem"]["formation_id"]}
)[0]
else: # what's the fuck ?
I["formation"] = {
)
if formation_dicts:
formation_dict = formation_dicts[0]
if formation_dict is None: # what's the fuck ?
formation_dict = {
"acronyme": "?",
"code_specialite": "",
"dept_id": 1,
@ -166,6 +169,7 @@ def formsemestre_bulletinetud_dict(formsemestre_id, etudid, version="long"):
"type_parcours": 0,
"version": 0,
}
I["formation"] = formation_dict
I["parcours"] = sco_codes_parcours.get_parcours_from_code(
I["formation"]["type_parcours"]
)

View File

@ -299,21 +299,21 @@ def formsemestre_bulletinetud(
raise ScoInvalidIdType(
"formsemestre_bulletinetud: formsemestre_id must be an integer !"
)
formsemestre = FormSemestre.query.get_or_404(formsemestre_id)
formsemestre = FormSemestre.query.filter_by(
formsemestre_id=formsemestre_id, dept_id=g.scodoc_dept_id
).first_or_404()
if etudid:
etud = models.Identite.query.get_or_404(etudid)
etud = models.Identite.query.filter_by(
etudid=etudid, dept_id=formsemestre.dept_id
).first_or_404()
elif code_nip:
etud = (
models.Identite.query.filter_by(code_nip=str(code_nip))
.filter_by(dept_id=formsemestre.dept_id)
.first_or_404()
)
etud = models.Identite.query.filter_by(
code_nip=str(code_nip), dept_id=formsemestre.dept_id
).first_or_404()
elif code_ine:
etud = (
models.Identite.query.filter_by(code_ine=str(code_ine))
.filter_by(dept_id=formsemestre.dept_id)
.first_or_404()
)
etud = models.Identite.query.filter_by(
code_ine=str(code_ine), dept_id=formsemestre.dept_id
).first_or_404()
else:
raise ScoValueError(
"Paramètre manquant: spécifier etudid, code_nip ou code_ine"