From 814a3802e96b45764949c942cfbd7a740490de9b Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Wed, 12 Jul 2023 22:11:33 +0200 Subject: [PATCH 1/3] =?UTF-8?q?Fix:=20association=20d'un=20formsemetre=20?= =?UTF-8?q?=C3=A0=20une=20nouvelle=20formation=20si=20des=20=C3=A9l=C3=A9m?= =?UTF-8?q?ents=20font=20r=C3=A9f=C3=A9rence=20=C3=A0=20des=20UEs=20qui=20?= =?UTF-8?q?ne=20sont=20plus=20dans=20la=20formation=20du=20semestre=20(sic?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/scodoc/sco_formation_versions.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/scodoc/sco_formation_versions.py b/app/scodoc/sco_formation_versions.py index 9cce0c3ae..e4a5937ef 100644 --- a/app/scodoc/sco_formation_versions.py +++ b/app/scodoc/sco_formation_versions.py @@ -200,7 +200,7 @@ def do_formsemestres_associate_new_version( # New formation: ( - formation_id, + new_formation_id, modules_old2new, ues_old2new, ) = sco_formations.formation_create_new_version(formation_id, redirect=False) @@ -219,7 +219,7 @@ def do_formsemestres_associate_new_version( # re-associate for formsemestre_id in formsemestre_ids: formsemestre = FormSemestre.get_formsemestre(formsemestre_id) - formsemestre.formation_id = formation_id + formsemestre.formation_id = new_formation_id db.session.add(formsemestre) _reassociate_moduleimpls(formsemestre, ues_old2new, modules_old2new) @@ -246,8 +246,12 @@ def _reassociate_moduleimpls( Evaluation.moduleimpl_id == ModuleImpl.id, ModuleImpl.formsemestre_id == formsemestre.id, ): - poids.ue_id = ues_old2new[poids.ue_id] - db.session.add(poids) + if poids.ue_id in ues_old2new: + poids.ue_id = ues_old2new[poids.ue_id] + db.session.add(poids) + else: + # poids vers une UE qui n'est pas ou plus dans notre formation + db.session.delete(poids) # update decisions: for event in ScolarEvent.query.filter_by(formsemestre_id=formsemestre.id): @@ -258,8 +262,9 @@ def _reassociate_moduleimpls( for validation in ScolarFormSemestreValidation.query.filter_by( formsemestre_id=formsemestre.id ): - if validation.ue_id is not None: + if (validation.ue_id is not None) and validation.ue_id in ues_old2new: validation.ue_id = ues_old2new[validation.ue_id] + # si l'UE n'est pas ou plus dans notre formation, laisse. db.session.add(validation) db.session.commit() From 417b3b8383c0d79c40409b7705649ab1aa2a22a1 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Wed, 12 Jul 2023 22:36:03 +0200 Subject: [PATCH 2/3] Fix: test bloquant sur structire groupe defaut --- app/scodoc/sco_groups.py | 2 +- sco_version.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/scodoc/sco_groups.py b/app/scodoc/sco_groups.py index 932c014a6..8486fa952 100644 --- a/app/scodoc/sco_groups.py +++ b/app/scodoc/sco_groups.py @@ -241,7 +241,7 @@ def get_default_group(formsemestre_id, fix_if_missing=False): return group.id # debug check if len(r) != 1: - raise ScoException(f"invalid group structure for {formsemestre_id}") + log(f"invalid group structure for {formsemestre_id}: {len(r)}") group_id = r[0]["group_id"] return group_id diff --git a/sco_version.py b/sco_version.py index fa162ac94..10a961f96 100644 --- a/sco_version.py +++ b/sco_version.py @@ -1,7 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- -SCOVERSION = "9.5.1" +SCOVERSION = "9.5.2" SCONAME = "ScoDoc" From 2c93c35aa7972b502ddbda69b35cb40773317647 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Thu, 13 Jul 2023 12:55:19 +0200 Subject: [PATCH 3/3] Fix: robustifie export xml de groupes sans noms --- app/scodoc/sco_formation_recap.py | 3 ++- app/scodoc/sco_groups.py | 8 ++++---- sco_version.py | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/scodoc/sco_formation_recap.py b/app/scodoc/sco_formation_recap.py index c940b76e1..7717e4f91 100644 --- a/app/scodoc/sco_formation_recap.py +++ b/app/scodoc/sco_formation_recap.py @@ -28,13 +28,14 @@ """Table recap formation (avec champs éditables) """ import io -from zipfile import ZipFile, BadZipfile +from zipfile import ZipFile from flask import Response from flask import send_file, url_for from flask import g, request from flask_login import current_user +from app import db from app.models import Formation, FormSemestre, Matiere, Module, UniteEns from app.scodoc.gen_tables import GenTable diff --git a/app/scodoc/sco_groups.py b/app/scodoc/sco_groups.py index 8486fa952..17b76f2ca 100644 --- a/app/scodoc/sco_groups.py +++ b/app/scodoc/sco_groups.py @@ -587,7 +587,7 @@ def XMLgetGroupsInPartition(partition_id): # was XMLgetGroupesTD x_group = Element( "group", partition_id=str(partition_id), - partition_name=partition["partition_name"], + partition_name=partition["partition_name"] or "", groups_editable=str(int(partition["groups_editable"])), group_id="_none_", group_name="", @@ -599,9 +599,9 @@ def XMLgetGroupsInPartition(partition_id): # was XMLgetGroupesTD Element( "etud", etudid=str(etud["etudid"]), - sexe=etud["civilite_str"], - nom=sco_etud.format_nom(etud["nom"]), - prenom=sco_etud.format_prenom(etud["prenom"]), + sexe=etud["civilite_str"] or "", + nom=sco_etud.format_nom(etud["nom"] or ""), + prenom=sco_etud.format_prenom(etud["prenom"] or ""), origin=_comp_etud_origin(etud, formsemestre), ) ) diff --git a/sco_version.py b/sco_version.py index 10a961f96..99628f42c 100644 --- a/sco_version.py +++ b/sco_version.py @@ -1,7 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- -SCOVERSION = "9.5.2" +SCOVERSION = "9.5.3" SCONAME = "ScoDoc"