backport fix formations

This commit is contained in:
Emmanuel Viennet 2022-01-08 20:07:13 +01:00
parent 24bfb8a13d
commit 9172282451

View File

@ -5,6 +5,7 @@ from app import db
from app.comp import df_cache from app.comp import df_cache
from app.models import SHORT_STR_LEN from app.models import SHORT_STR_LEN
from app.models.modules import Module from app.models.modules import Module
from app.models.ues import UniteEns
from app.scodoc import notesdb as ndb from app.scodoc import notesdb as ndb
from app.scodoc import sco_cache from app.scodoc import sco_cache
from app.scodoc import sco_codes_parcours from app.scodoc import sco_codes_parcours
@ -130,8 +131,14 @@ class Formation(db.Model):
db.session.add(mod) db.session.add(mod)
change = True change = True
# --- Numéros de modules # --- 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()) 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() db.session.commit()
if change: if change: