API: /formsemestres/query?ine=xxxx

This commit is contained in:
Emmanuel Viennet 2022-10-28 15:48:27 +02:00 committed by iziram
parent cfcb100ab7
commit 0de35b5400
2 changed files with 8 additions and 7 deletions

View File

@ -104,7 +104,7 @@ def formsemestres_query():
dept_acronym = request.args.get("dept_acronym") dept_acronym = request.args.get("dept_acronym")
dept_id = request.args.get("dept_id") dept_id = request.args.get("dept_id")
nip = request.args.get("nip") nip = request.args.get("nip")
ine = request.args.get("nip") ine = request.args.get("ine")
formsemestres = FormSemestre.query formsemestres = FormSemestre.query
if g.scodoc_dept: if g.scodoc_dept:
formsemestres = formsemestres.filter_by(dept_id=g.scodoc_dept_id) formsemestres = formsemestres.filter_by(dept_id=g.scodoc_dept_id)
@ -130,18 +130,19 @@ def formsemestres_query():
formsemestres = formsemestres.join(FormSemestreEtape).filter( formsemestres = formsemestres.join(FormSemestreEtape).filter(
FormSemestreEtape.etape_apo == etape_apo FormSemestreEtape.etape_apo == etape_apo
) )
inscr_joined = False
if nip is not None: if nip is not None:
formsemestres = ( formsemestres = (
formsemestres.join(FormSemestreInscription) formsemestres.join(FormSemestreInscription)
.join(Identite) .join(Identite)
.filter_by(code_nip=nip) .filter_by(code_nip=nip)
) )
inscr_joined = True
if ine is not None: if ine is not None:
formsemestres = ( if not inscr_joined:
formsemestres.join(FormSemestreInscription) formsemestres = formsemestres.join(FormSemestreInscription).join(Identite)
.join(Identite) formsemestres = formsemestres.filter_by(code_ine=ine)
.filter_by(code_ine=ine)
)
return jsonify([formsemestre.to_dict_api() for formsemestre in formsemestres]) return jsonify([formsemestre.to_dict_api() for formsemestre in formsemestres])

View File

@ -13,7 +13,7 @@ Pour utiliser l'API, (sur une base quelconque):
``` ```
cd /opt/scodoc/tests/api cd /opt/scodoc/tests/api
python -i exemple-api-basic.p python -i exemple-api-basic.py
>>> admin_h = get_auth_headers("admin", "xxx") >>> admin_h = get_auth_headers("admin", "xxx")
>>> GET("/etudiant/etudid/14806", headers=admin_h) >>> GET("/etudiant/etudid/14806", headers=admin_h)
``` ```