From a63ed6c0ef2aefc5e8ef78ca7009500fe2bc74ae Mon Sep 17 00:00:00 2001 From: Iziram Date: Mon, 8 Jan 2024 19:06:44 +0100 Subject: [PATCH] Assiduites : justifier depuis tableau closes #841 --- app/tables/liste_assiduites.py | 12 ++++++++++++ app/views/assiduites.py | 18 +++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/app/tables/liste_assiduites.py b/app/tables/liste_assiduites.py index b9d031b1..17d04c27 100644 --- a/app/tables/liste_assiduites.py +++ b/app/tables/liste_assiduites.py @@ -415,6 +415,18 @@ class RowAssiJusti(tb.Row): ) html.append(f'') # utiliser url_for + # Justifier (si type Assiduité et est_just faux) + + if self.ligne["type"] == "assiduite" and not self.ligne["est_just"]: + url = url_for( + "assiduites.tableau_assiduite_actions", + type=self.ligne["type"], + action="justifier", + obj_id=self.ligne["obj_id"], + scodoc_dept=g.scodoc_dept, + ) + html.append(f'🗄️') + self.add_cell( "actions", "", diff --git a/app/views/assiduites.py b/app/views/assiduites.py index 8317702b..5e1a4b0b 100644 --- a/app/views/assiduites.py +++ b/app/views/assiduites.py @@ -1458,7 +1458,7 @@ def _prepare_tableau( def tableau_assiduite_actions(): """Edition/suppression/information sur une assiduité ou un justificatif type = "assiduite" | "justificatif" - action = "supprimer" | " + action = "supprimer" | "details" | "justifier" """ obj_type: str = request.args.get("type", "assiduite") action: str = request.args.get("action", "details") @@ -1480,6 +1480,22 @@ def tableau_assiduite_actions(): return redirect(request.referrer) + # Justification d'une assiduité depuis le tableau + if action == "justifier" and obj_type == "assiduite": + # Création du justificatif correspondant + justificatif_correspondant: Justificatif = Justificatif.create_justificatif( + etudiant=objet.etudiant, + date_debut=objet.date_debut, + date_fin=objet.date_fin, + etat=scu.EtatJustificatif.VALIDE, + user_id=current_user.id, + ) + + compute_assiduites_justified(objet.etudiant.id, [justificatif_correspondant]) + + flash(f"{objet_name} justifiée") + return redirect(request.referrer) + if request.method == "GET": module: str | int = "" # moduleimpl_id ou chaine libre