diff --git a/app/api/formsemestres.py b/app/api/formsemestres.py index c024f6e7f..e80da766a 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 0ef58af47..b9095e12d 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) ```