From 9172282451bafe3565dcb16d3e319ef4bd4c64b0 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sat, 8 Jan 2022 20:07:13 +0100 Subject: [PATCH] backport fix formations --- app/models/formations.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/models/formations.py b/app/models/formations.py index e926471c2..e2273c3b6 100644 --- a/app/models/formations.py +++ b/app/models/formations.py @@ -5,6 +5,7 @@ from app import db from app.comp import df_cache from app.models import SHORT_STR_LEN from app.models.modules import Module +from app.models.ues import UniteEns from app.scodoc import notesdb as ndb from app.scodoc import sco_cache from app.scodoc import sco_codes_parcours @@ -130,8 +131,14 @@ class Formation(db.Model): db.session.add(mod) change = True # --- Numéros de modules - if Module.query.filter_by(formation_id=220, numero=None).count() > 0: + if Module.query.filter_by(formation_id=self.id, numero=None).count() > 0: scu.objects_renumber(db, self.modules.all()) + # --- Types d'UE (avant de rendre le type non nullable) + ues_sans_type = UniteEns.query.filter_by(formation_id=self.id, type=None) + if ues_sans_type.count() > 0: + for ue in ues_sans_type: + ue.type = 0 + db.session.add(ue) db.session.commit() if change: