1
0
forked from ScoDoc/ScoDoc

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_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])

View File

@ -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)
```