From 515cbaf406cc7d697bcbd95d03d2942e280bbbcb Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Fri, 15 Dec 2023 01:31:15 +0100 Subject: [PATCH] Fix: cache inval. apres saisie jutif indiv. --- app/scodoc/sco_assiduites.py | 4 ++-- app/tables/visu_assiduites.py | 2 +- .../assiduites/pages/{visu_assi.j2 => visu_assi_group.j2} | 2 +- app/views/assiduites.py | 5 +++-- 4 files changed, 7 insertions(+), 6 deletions(-) rename app/templates/assiduites/pages/{visu_assi.j2 => visu_assi_group.j2} (92%) diff --git a/app/scodoc/sco_assiduites.py b/app/scodoc/sco_assiduites.py index c80a5f55..6d547489 100644 --- a/app/scodoc/sco_assiduites.py +++ b/app/scodoc/sco_assiduites.py @@ -532,7 +532,7 @@ def get_assiduites_count_in_interval( return r -def invalidate_assiduites_count(etudid, sem): +def invalidate_assiduites_count(etudid: int, sem: dict): """Invalidate (clear) cached counts""" date_debut = sem["date_debut_iso"] date_fin = sem["date_fin_iso"] @@ -541,7 +541,7 @@ def invalidate_assiduites_count(etudid, sem): sco_cache.AbsSemEtudCache.delete(key) -def invalidate_assiduites_count_sem(sem): +def invalidate_assiduites_count_sem(sem: dict): """Invalidate (clear) cached abs counts for all the students of this semestre""" inscriptions = ( sco_formsemestre_inscriptions.do_formsemestre_inscription_listinscrits( diff --git a/app/tables/visu_assiduites.py b/app/tables/visu_assiduites.py index 4a48728f..07fb7dec 100644 --- a/app/tables/visu_assiduites.py +++ b/app/tables/visu_assiduites.py @@ -29,7 +29,7 @@ class TableAssi(tb.Table): **kwargs, ): self.rows: list["RowEtud"] = [] # juste pour que VSCode nous aide sur .rows - classes = ["gt_table", "gt_left"] + classes = ["gt_table"] self.dates = [str(dates[0]) + "T00:00", str(dates[1]) + "T23:59"] self.formsemestre = formsemestre super().__init__( diff --git a/app/templates/assiduites/pages/visu_assi.j2 b/app/templates/assiduites/pages/visu_assi_group.j2 similarity index 92% rename from app/templates/assiduites/pages/visu_assi.j2 rename to app/templates/assiduites/pages/visu_assi_group.j2 index 88c30d42..04f56cb2 100644 --- a/app/templates/assiduites/pages/visu_assi.j2 +++ b/app/templates/assiduites/pages/visu_assi_group.j2 @@ -34,7 +34,7 @@ function stats() { const deb = Date.fromFRA(document.querySelector('#stats_date_debut').value); const fin = Date.fromFRA(document.querySelector('#stats_date_fin').value); - location.href = `VisualisationAssiduitesGroupe?group_ids=${group_ids}&date_debut=${deb}&date_fin=${fin}`; + location.href = `visu_assi_group?group_ids=${group_ids}&date_debut=${deb}&date_fin=${fin}`; } window.addEventListener('load', () => { diff --git a/app/views/assiduites.py b/app/views/assiduites.py index 9b9858f8..ee32f327 100644 --- a/app/views/assiduites.py +++ b/app/views/assiduites.py @@ -692,6 +692,7 @@ def _record_justificatif_etud( return False db.session.commit() compute_assiduites_justified(etud.id, [just]) + scass.simple_invalidate_cache(just.to_dict(), etud.id) flash("Justificatif enregistré") return True except ScoValueError as exc: @@ -1209,7 +1210,7 @@ def etat_abs_date(): ) -@bp.route("/VisualisationAssiduitesGroupe") +@bp.route("/visu_assi_group") @scodoc @permission_required(Permission.ScoView) def visu_assi_group(): @@ -1263,7 +1264,7 @@ def visu_assi_group(): # Génération de la page return render_template( - "assiduites/pages/visu_assi.j2", + "assiduites/pages/visu_assi_group.j2", assi_metric=scu.translate_assiduites_metric( scu.translate_assiduites_metric( sco_preferences.get_preference(