From dae7486d3ff19c9c67c485f8cec134d66cd22fb7 Mon Sep 17 00:00:00 2001 From: iziram Date: Mon, 17 Apr 2023 15:35:42 +0200 Subject: [PATCH] Assiduites : Fonctionnement BackEnd + API --- app/api/etudiants.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/app/api/etudiants.py b/app/api/etudiants.py index 1357d9bdd..462a81ec0 100755 --- a/app/api/etudiants.py +++ b/app/api/etudiants.py @@ -170,6 +170,42 @@ def get_photo_image(etudid: int = None, nip: str = None, ine: str = None): return res +@api_web_bp.route("/etudiant/etudid//photo") +@api_web_bp.route("/etudiant/nip//photo") +@api_web_bp.route("/etudiant/ine//photo") +@login_required +@scodoc +@permission_required(Permission.ScoView) +def get_photo_image(etudid: int = None, nip: str = None, ine: str = None): + """ + Retourne la photo de l'étudiant + correspondant ou un placeholder si non existant. + + etudid : l'etudid de l'étudiant + nip : le code nip de l'étudiant + ine : le code ine de l'étudiant + + Attention : Ne peut être qu'utilisée en tant que route de département + """ + + etud = tools.get_etud(etudid, nip, ine) + + if etud is None: + return json_error( + 404, + message="étudiant inconnu", + ) + if not etudid: + filename = sco_photos.UNKNOWN_IMAGE_PATH + + size = request.args.get("size", "orig") + filename = sco_photos.photo_pathname(etud.photo_filename, size=size) + if not filename: + filename = sco_photos.UNKNOWN_IMAGE_PATH + res = sco_photos.build_image_response(filename) + return res + + @bp.route("/etudiants/etudid/", methods=["GET"]) @bp.route("/etudiants/nip/", methods=["GET"]) @bp.route("/etudiants/ine/", methods=["GET"])