From 9d72954cc1822b3de1d9802a199086e19adb7316 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Wed, 13 Jul 2022 12:03:53 +0200 Subject: [PATCH] =?UTF-8?q?Bulletins:=20v=C3=A9rification=20plus=20stricte?= =?UTF-8?q?=20des=20arguments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/scodoc/sco_bulletins.py | 12 ++++++++---- app/views/notes.py | 24 ++++++++++++------------ 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/app/scodoc/sco_bulletins.py b/app/scodoc/sco_bulletins.py index 989c7bd5..02445204 100644 --- a/app/scodoc/sco_bulletins.py +++ b/app/scodoc/sco_bulletins.py @@ -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"] ) diff --git a/app/views/notes.py b/app/views/notes.py index fe1774a7..111019d8 100644 --- a/app/views/notes.py +++ b/app/views/notes.py @@ -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"