From e02a324165f58ff4561a62924859f2e3628e6c76 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Mon, 14 Mar 2022 15:30:51 +0100 Subject: [PATCH] =?UTF-8?q?Fix:=20bul.=20DUT=20en=20json=20avec=20acc?= =?UTF-8?q?=C3=A8s=20par=20NIP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/scodoc/sco_bulletins.py | 5 ++--- app/views/notes.py | 38 ++++++++++++++++++------------------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/app/scodoc/sco_bulletins.py b/app/scodoc/sco_bulletins.py index b9ebdfcc1d..3bcb7a41c6 100644 --- a/app/scodoc/sco_bulletins.py +++ b/app/scodoc/sco_bulletins.py @@ -791,7 +791,7 @@ def etud_descr_situation_semestre( # ------ Page bulletin def formsemestre_bulletinetud( - etudid=None, + etud: Identite = None, formsemestre_id=None, format=None, version="long", @@ -801,14 +801,13 @@ def formsemestre_bulletinetud( ): "page bulletin de notes" format = format or "html" - etud: Identite = Identite.query.get_or_404(etudid) formsemestre: FormSemestre = FormSemestre.query.get(formsemestre_id) if not formsemestre: raise ScoValueError(f"semestre {formsemestre_id} inconnu !") bulletin = do_formsemestre_bulletinetud( formsemestre, - etudid, + etud.id, format=format, version=version, xml_with_decisions=xml_with_decisions, diff --git a/app/views/notes.py b/app/views/notes.py index 7ad5c11228..9f243cb940 100644 --- a/app/views/notes.py +++ b/app/views/notes.py @@ -291,25 +291,25 @@ def formsemestre_bulletinetud( if not isinstance(formsemestre_id, int): raise ScoInvalidIdType("formsemestre_id must be an integer !") formsemestre = FormSemestre.query.get_or_404(formsemestre_id) + if etudid: + etud = models.Identite.query.get_or_404(etudid) + elif code_nip: + etud = ( + models.Identite.query.filter_by(code_nip=str(code_nip)) + .filter_by(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() + ) + else: + raise ScoValueError( + "Paramètre manquant: spécifier etudid, code_nip ou code_ine" + ) if formsemestre.formation.is_apc() and format != "oldjson": - if etudid: - etud = models.Identite.query.get_or_404(etudid) - elif code_nip: - etud = ( - models.Identite.query.filter_by(code_nip=str(code_nip)) - .filter_by(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() - ) - else: - raise ScoValueError( - "Paramètre manquant: spécifier code_nip ou etudid ou code_ine" - ) if format == "json": r = bulletin_but.BulletinBUT(formsemestre) return jsonify( @@ -354,7 +354,7 @@ def formsemestre_bulletinetud( if format == "oldjson": format = "json" return sco_bulletins.formsemestre_bulletinetud( - etudid=etudid, + etud, formsemestre_id=formsemestre_id, format=format, version=version,