From 0f6824da374e638fd2148b1af3320a670d5391d1 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Fri, 28 Oct 2022 15:14:33 +0200 Subject: [PATCH] API: ajout /formsemestres/query?nip=xxxx --- app/api/formsemestres.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/app/api/formsemestres.py b/app/api/formsemestres.py index 3923a4e1..c024f6e7 100644 --- a/app/api/formsemestres.py +++ b/app/api/formsemestres.py @@ -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])