Edition UEs: renumérote si besoin

This commit is contained in:
Emmanuel Viennet 2022-12-03 22:52:01 +01:00 committed by iziram
parent f246d9e82c
commit ef1b28fe27

View File

@ -653,6 +653,12 @@ def ue_table(formation_id=None, semestre_idx=1, msg=""): # was ue_list
ues_obj = UniteEns.query.filter_by(
formation_id=formation_id, is_external=False
).order_by(UniteEns.semestre_idx, UniteEns.numero)
# safety check: renumérote les ue s'il en manque ou s'il y a des ex-aequo.
# cela facilite le travail de la passerelle !
numeros = {ue.numero for ue in ues_obj}
if (None in numeros) or len(numeros) < ues_obj.count():
scu.objects_renumber(db, ues_obj)
ues_externes_obj = UniteEns.query.filter_by(
formation_id=formation_id, is_external=True
)