forked from ScoDoc/ScoDoc
API: ajout /formsemestres/query?nip=xxxx
This commit is contained in:
parent
1c48758940
commit
cfcb100ab7
@ -22,6 +22,8 @@ from app.models import (
|
||||
Evaluation,
|
||||
FormSemestre,
|
||||
FormSemestreEtape,
|
||||
FormSemestreInscription,
|
||||
Identite,
|
||||
ModuleImpl,
|
||||
NotesNotes,
|
||||
)
|
||||
@ -95,11 +97,14 @@ def formsemestres_query():
|
||||
annee_scolaire : année de début de l'année scolaire
|
||||
dept_acronym : acronyme du département (eg "RT")
|
||||
dept_id : id du département
|
||||
ine ou nip: code d'un étudiant: ramène alors tous les semestres auxquels il est inscrit.
|
||||
"""
|
||||
etape_apo = request.args.get("etape_apo")
|
||||
annee_scolaire = request.args.get("annee_scolaire")
|
||||
dept_acronym = request.args.get("dept_acronym")
|
||||
dept_id = request.args.get("dept_id")
|
||||
nip = request.args.get("nip")
|
||||
ine = request.args.get("nip")
|
||||
formsemestres = FormSemestre.query
|
||||
if g.scodoc_dept:
|
||||
formsemestres = formsemestres.filter_by(dept_id=g.scodoc_dept_id)
|
||||
@ -125,7 +130,18 @@ def formsemestres_query():
|
||||
formsemestres = formsemestres.join(FormSemestreEtape).filter(
|
||||
FormSemestreEtape.etape_apo == etape_apo
|
||||
)
|
||||
|
||||
if nip is not None:
|
||||
formsemestres = (
|
||||
formsemestres.join(FormSemestreInscription)
|
||||
.join(Identite)
|
||||
.filter_by(code_nip=nip)
|
||||
)
|
||||
if ine is not None:
|
||||
formsemestres = (
|
||||
formsemestres.join(FormSemestreInscription)
|
||||
.join(Identite)
|
||||
.filter_by(code_ine=ine)
|
||||
)
|
||||
return jsonify([formsemestre.to_dict_api() for formsemestre in formsemestres])
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user