diff --git a/app/api/justificatifs.py b/app/api/justificatifs.py index 9c1fd001..099d9e6c 100644 --- a/app/api/justificatifs.py +++ b/app/api/justificatifs.py @@ -151,6 +151,48 @@ def justificatifs_dept(dept_id: int = None, with_query: bool = False): return data_set +@bp.route( + "/justificatifs/formsemestre/", defaults={"with_query": False} +) +@api_web_bp.route( + "/justificatifs/formsemestre/", defaults={"with_query": False} +) +@bp.route( + "/justificatifs/formsemestre//query", + defaults={"with_query": True}, +) +@api_web_bp.route( + "/justificatifs/formsemestre//query", + defaults={"with_query": True}, +) +@login_required +@scodoc +@as_json +@permission_required(Permission.ScoView) +def justificatifs_formsemestre(formsemestre_id: int, with_query: bool = False): + """Retourne tous les justificatifs du formsemestre""" + formsemestre: FormSemestre = None + formsemestre_id = int(formsemestre_id) + formsemestre = FormSemestre.query.filter_by(id=formsemestre_id).first() + + if formsemestre is None: + return json_error(404, "le paramètre 'formsemestre_id' n'existe pas") + + justificatifs_query = scass.filter_by_formsemestre( + Justificatif.query, Justificatif, formsemestre + ) + + if with_query: + justificatifs_query = _filter_manager(request, justificatifs_query) + + data_set: list[dict] = [] + for justi in justificatifs_query.all(): + data = justi.to_dict(format_api=True) + data_set.append(data) + + return data_set + + @bp.route("/justificatif//create", methods=["POST"]) @api_web_bp.route("/justificatif//create", methods=["POST"]) @bp.route("/justificatif/etudid//create", methods=["POST"])