From 0de35b540066460b7d3b4bc312adb535c6dfb2b7 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Fri, 28 Oct 2022 15:48:27 +0200 Subject: [PATCH] API: /formsemestres/query?ine=xxxx --- app/api/formsemestres.py | 13 +++++++------ tests/api/exemple-api-basic.py | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/api/formsemestres.py b/app/api/formsemestres.py index c024f6e7..e80da766 100644 --- a/app/api/formsemestres.py +++ b/app/api/formsemestres.py @@ -104,7 +104,7 @@ def formsemestres_query(): dept_acronym = request.args.get("dept_acronym") dept_id = request.args.get("dept_id") nip = request.args.get("nip") - ine = request.args.get("nip") + ine = request.args.get("ine") formsemestres = FormSemestre.query if g.scodoc_dept: formsemestres = formsemestres.filter_by(dept_id=g.scodoc_dept_id) @@ -130,18 +130,19 @@ def formsemestres_query(): formsemestres = formsemestres.join(FormSemestreEtape).filter( FormSemestreEtape.etape_apo == etape_apo ) + inscr_joined = False if nip is not None: formsemestres = ( formsemestres.join(FormSemestreInscription) .join(Identite) .filter_by(code_nip=nip) ) + inscr_joined = True if ine is not None: - formsemestres = ( - formsemestres.join(FormSemestreInscription) - .join(Identite) - .filter_by(code_ine=ine) - ) + if not inscr_joined: + formsemestres = formsemestres.join(FormSemestreInscription).join(Identite) + formsemestres = formsemestres.filter_by(code_ine=ine) + return jsonify([formsemestre.to_dict_api() for formsemestre in formsemestres]) diff --git a/tests/api/exemple-api-basic.py b/tests/api/exemple-api-basic.py index 0ef58af4..b9095e12 100644 --- a/tests/api/exemple-api-basic.py +++ b/tests/api/exemple-api-basic.py @@ -13,7 +13,7 @@ Pour utiliser l'API, (sur une base quelconque): ``` cd /opt/scodoc/tests/api -python -i exemple-api-basic.p +python -i exemple-api-basic.py >>> admin_h = get_auth_headers("admin", "xxx") >>> GET("/etudiant/etudid/14806", headers=admin_h) ```