From c361ccb362d2716340348e0ccf8650f8ec7307bf Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Mon, 14 Feb 2022 18:33:36 +0100 Subject: [PATCH] Edition formation / invalidation caches --- app/scodoc/sco_edit_formation.py | 1 + app/scodoc/sco_edit_matiere.py | 10 ++++++---- app/scodoc/sco_edit_module.py | 12 +++++++----- app/scodoc/sco_edit_ue.py | 7 ++++--- app/templates/pn/form_ues.html | 5 +++++ app/templates/pn/ue_infos.html | 2 +- 6 files changed, 24 insertions(+), 13 deletions(-) diff --git a/app/scodoc/sco_edit_formation.py b/app/scodoc/sco_edit_formation.py index 7ba9ad40c..48caf2d5a 100644 --- a/app/scodoc/sco_edit_formation.py +++ b/app/scodoc/sco_edit_formation.py @@ -365,6 +365,7 @@ def ue_move(ue_id, after=0, redirect=1): if len({o.numero for o in others}) != len(others): # il y a des numeros identiques ! scu.objects_renumber(db, others) + ue.formation.invalidate_cached_sems() if len(others) > 1: idx = [u.id for u in others].index(ue.id) neigh = None # object to swap with diff --git a/app/scodoc/sco_edit_matiere.py b/app/scodoc/sco_edit_matiere.py index 13ddb2a99..fb40c2b0d 100644 --- a/app/scodoc/sco_edit_matiere.py +++ b/app/scodoc/sco_edit_matiere.py @@ -88,13 +88,14 @@ def do_matiere_create(args): r = _matiereEditor.create(cnx, args) # news - F = sco_formations.formation_list(args={"formation_id": ue["formation_id"]})[0] + formation = Formation.query.get(ue["formation_id"]) sco_news.add( typ=sco_news.NEWS_FORM, object=ue["formation_id"], - text="Modification de la formation %(acronyme)s" % F, + text="Modification de la formation {formation.acronyme}", max_frequency=3, ) + formation.invalidate_cached_sems() return r @@ -195,13 +196,14 @@ def do_matiere_delete(oid): _matiereEditor.delete(cnx, oid) # news - F = sco_formations.formation_list(args={"formation_id": ue["formation_id"]})[0] + formation = Formation.query.get(ue["formation_id"]) sco_news.add( typ=sco_news.NEWS_FORM, object=ue["formation_id"], - text="Modification de la formation %(acronyme)s" % F, + text="Modification de la formation {formation.acronyme}", max_frequency=3, ) + formation.invalidate_cached_sems() def matiere_delete(matiere_id=None): diff --git a/app/scodoc/sco_edit_module.py b/app/scodoc/sco_edit_module.py index f7b25989e..41a25d090 100644 --- a/app/scodoc/sco_edit_module.py +++ b/app/scodoc/sco_edit_module.py @@ -104,13 +104,14 @@ def do_module_create(args) -> int: r = _moduleEditor.create(cnx, args) # news - F = sco_formations.formation_list(args={"formation_id": args["formation_id"]})[0] + formation = Formation.query.get(args["formation_id"]) sco_news.add( typ=sco_news.NEWS_FORM, - object=args["formation_id"], - text="Modification de la formation %(acronyme)s" % F, + object=formation.id, + text=f"Modification de la formation {formation.acronyme}", max_frequency=3, ) + formation.invalidate_cached_sems() return r @@ -394,13 +395,14 @@ def do_module_delete(oid): _moduleEditor.delete(cnx, oid) # news - F = sco_formations.formation_list(args={"formation_id": mod["formation_id"]})[0] + formation = module.formation sco_news.add( typ=sco_news.NEWS_FORM, object=mod["formation_id"], - text="Modification de la formation %(acronyme)s" % F, + text=f"Modification de la formation {formation.acronyme}", max_frequency=3, ) + formation.invalidate_cached_sems() def module_delete(module_id=None): diff --git a/app/scodoc/sco_edit_ue.py b/app/scodoc/sco_edit_ue.py index 7675e45ec..17cdc8c07 100644 --- a/app/scodoc/sco_edit_ue.py +++ b/app/scodoc/sco_edit_ue.py @@ -128,13 +128,14 @@ def do_ue_create(args): formation = Formation.query.get(args["formation_id"]) formation.invalidate_module_coefs() # news - F = sco_formations.formation_list(args={"formation_id": args["formation_id"]})[0] + formation = Formation.query.get(args["formation_id"]) sco_news.add( typ=sco_news.NEWS_FORM, object=args["formation_id"], - text="Modification de la formation %(acronyme)s" % F, + text="Modification de la formation {formation.acronyme}", max_frequency=3, ) + formation.invalidate_cached_sems() return ue_id @@ -361,7 +362,7 @@ def ue_edit(ue_id=None, create=False, formation_id=None, default_semestre_idx=No { "size": 12, "title": "Code UE", - "explanation": "code interne (optionnel). Toutes les UE partageant le même code (et le même code de formation) sont compatibles (compensation de semestres, capitalisation d'UE). Voir liste ci-dessous.", + "explanation": "code interne (non vide). Toutes les UE partageant le même code (et le même code de formation) sont compatibles (compensation de semestres, capitalisation d'UE). Voir liste ci-dessous.", }, ), ( diff --git a/app/templates/pn/form_ues.html b/app/templates/pn/form_ues.html index e56e19875..350d12d82 100644 --- a/app/templates/pn/form_ues.html +++ b/app/templates/pn/form_ues.html @@ -35,6 +35,11 @@ {{ue.acronyme}} {{ue.titre}} + {% set virg = joiner(", ") %} + ( + {%- if ue.ue_code -%}{{ virg() }}code {{ue.ue_code}} {%- endif -%} + {{ virg() }}{{ue.ects or 0}} ECTS) + {% if editable and not ue.is_locked() %} diff --git a/app/templates/pn/ue_infos.html b/app/templates/pn/ue_infos.html index b45c0b9bc..c5a0f7777 100644 --- a/app/templates/pn/ue_infos.html +++ b/app/templates/pn/ue_infos.html @@ -12,7 +12,7 @@
  • {{ue.acronyme}}