From 55b786e655512531aab037a20d729d77328426a9 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Wed, 27 Apr 2022 09:24:20 +0200 Subject: [PATCH] API: formsemestre/apo/ --- app/api/etudiants.py | 2 -- app/api/formations.py | 23 ----------------------- app/api/formsemestres.py | 17 +++++++++++++++++ 3 files changed, 17 insertions(+), 25 deletions(-) diff --git a/app/api/etudiants.py b/app/api/etudiants.py index 9f5b89ec..964dcde9 100644 --- a/app/api/etudiants.py +++ b/app/api/etudiants.py @@ -344,8 +344,6 @@ def etudiant_bulletin_semestre( } } """ - # Fonction utilisée : app.scodoc.sco_bulletins_json.make_json_formsemestre_bulletinetud() - formsemestre = models.FormSemestre.query.filter_by( id=formsemestre_id ).first_or_404() diff --git a/app/api/formations.py b/app/api/formations.py index 6840cf02..f7d1a642 100644 --- a/app/api/formations.py +++ b/app/api/formations.py @@ -188,29 +188,6 @@ def formation_export_by_formation_id(formation_id: int, export_ids=False): return jsonify(data) -@bp.route("/formations/apo/", methods=["GET"]) -@token_permission_required(Permission.APIView) -def formsemestre_apo(etape_apo: int): - """ - Retourne les informations sur les formsemestres - - etape_apo : l'id d'une étape apogée - """ - # Récupération des formsemestres - apos = models.FormSemestreEtape.query.filter_by(etape_apo=etape_apo) - - data = [] - # Filtre les formsemestres correspondant + mise en forme des données - for apo in apos: - formsem = models.FormSemestre.query.filter_by( - id=apo["formsemestre_id"] - ).first_or_404() - data.append(formsem.to_dict()) - - return jsonify(data) - # return error_response(501, message="Not implemented") - - @bp.route("/formations/moduleimpl/", methods=["GET"]) @token_permission_required(Permission.APIView) def moduleimpls(moduleimpl_id: int): diff --git a/app/api/formsemestres.py b/app/api/formsemestres.py index 22bb770e..9704d753 100644 --- a/app/api/formsemestres.py +++ b/app/api/formsemestres.py @@ -7,6 +7,7 @@ from app.api import bp from app.api.errors import error_response from app.api.auth import token_permission_required from app.api.tools import get_etu_from_etudid_or_nip_or_ine +from app.models import FormSemestre, FormSemestreEtape from app.scodoc.sco_bulletins import get_formsemestre_bulletin_etud_json from app.scodoc.sco_bulletins_json import make_json_formsemestre_bulletinetud from app.scodoc.sco_permissions import Permission @@ -60,6 +61,22 @@ def formsemestre(formsemestre_id: int): return jsonify(data) +@bp.route("/formsemestre/apo/", methods=["GET"]) +@token_permission_required(Permission.APIView) +def formsemestre_apo(etape_apo: str): + """ + Retourne les informations sur les formsemestres + + etape_apo : l'id d'une étape apogée + """ + formsemestres = FormSemestre.query.filter( + FormSemestreEtape.etape_apo == etape_apo, + FormSemestreEtape.formsemestre_id == FormSemestre.id, + ) + + return jsonify([formsemestre.to_dict() for formsemestre in formsemestres]) + + @bp.route( "/formsemestre//departements//etudiant/etudid//bulletin", methods=["GET"],