From 53a4b6cdd71f1a934a8c4acca6e8f5faacf139f0 Mon Sep 17 00:00:00 2001 From: leonard_montalbano Date: Fri, 17 Jun 2022 15:46:17 +0200 Subject: [PATCH] ajout de la route /formations --- app/api/formations.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/api/formations.py b/app/api/formations.py index f8842b90d..30e773954 100644 --- a/app/api/formations.py +++ b/app/api/formations.py @@ -10,6 +10,22 @@ from app.models.formations import Formation from app.scodoc import sco_formations from app.scodoc.sco_permissions import Permission +@bp.route("/formations", methods=["GET"]) +@token_auth.login_required +@token_permission_required(Permission.APIView) +def formations(): + """ + Retourne la liste de toutes les formations (tous départements) + + Exemple de résultat : + """ + # Récupération de toutes les formations + list_formations = models.Formation.query.all() + + # Mise en forme des données + data = [d.to_dict() for d in list_formations] + + return jsonify(data) @bp.route("/formations_ids", methods=["GET"]) @token_auth.login_required