From 5e0922a4bf413726709f9d3d26bde2f1021817c6 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Fri, 13 Jan 2023 20:05:39 -0300 Subject: [PATCH] Fix #559 --- app/scodoc/sco_formsemestre_edit.py | 28 ++++++++++++++++++---------- app/scodoc/sco_synchro_etuds.py | 2 +- app/views/notes.py | 2 +- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/app/scodoc/sco_formsemestre_edit.py b/app/scodoc/sco_formsemestre_edit.py index 5a776c35b..399cf05db 100644 --- a/app/scodoc/sco_formsemestre_edit.py +++ b/app/scodoc/sco_formsemestre_edit.py @@ -28,7 +28,7 @@ """Form choix modules / responsables et creation formsemestre """ import flask -from flask import url_for, flash +from flask import url_for, flash, redirect from flask import g, request from flask_login import current_user @@ -177,10 +177,12 @@ def do_formsemestre_createwithmodules(edit=False, formsemestre: FormSemestre = N uid2display[u.id] = u.get_nomplogin() allowed_user_names = list(uid2display.values()) + [""] # - formation_id = int(vals["formation_id"]) - formation = Formation.query.get(formation_id) - if formation is None: - raise ScoValueError("Formation inexistante !") + if formsemestre: + formation = formsemestre.formation + else: + formation_id = int(vals["formation_id"]) + formation = Formation.query.get_or_404(formation_id) + is_apc = formation.is_apc() if not edit: initvalues = {"titre": _default_sem_title(formation)} @@ -236,7 +238,7 @@ def do_formsemestre_createwithmodules(edit=False, formsemestre: FormSemestre = N else: modules = ( Module.query.filter( - Module.formation_id == formation_id, UniteEns.id == Module.ue_id + Module.formation_id == formation.id, UniteEns.id == Module.ue_id ) .order_by(Module.module_type, UniteEns.numero, Module.numero) .all() @@ -254,7 +256,7 @@ def do_formsemestre_createwithmodules(edit=False, formsemestre: FormSemestre = N # modform = [ ("formsemestre_id", {"input_type": "hidden"}), - ("formation_id", {"input_type": "hidden", "default": formation_id}), + ("formation_id", {"input_type": "hidden", "default": formation.id}), ( "date_debut", { @@ -435,7 +437,7 @@ def do_formsemestre_createwithmodules(edit=False, formsemestre: FormSemestre = N ) if edit: formtit = f""" -

Modifier les coefficients des UE capitalisées

@@ -772,7 +774,7 @@ def do_formsemestre_createwithmodules(edit=False, formsemestre: FormSemestre = N if tf[0] == 0 or msg: return f"""

Formation {formation.titre} ({formation.acronyme}), version { formation.version}, code {formation.formation_code}

@@ -1769,7 +1771,13 @@ def formsemestre_edit_uecoefs(formsemestre_id, err_ue_id=None): if tf[0] == 0: return "\n".join(H) + tf[1] + footer elif tf[0] == -1: - return "

annulation

" + return redirect( + url_for( + "notes.formsemestre_editwithmodules", + scodoc_dept=g.scodoc_dept, + formsemestre_id=formsemestre_id, + ) + ) else: # change values # 1- supprime les coef qui ne sont plus forcés diff --git a/app/scodoc/sco_synchro_etuds.py b/app/scodoc/sco_synchro_etuds.py index 4c05d9604..2c80db6fd 100644 --- a/app/scodoc/sco_synchro_etuds.py +++ b/app/scodoc/sco_synchro_etuds.py @@ -102,7 +102,7 @@ def formsemestre_synchro_etuds( if not sem["etapes"]: raise ScoValueError( """opération impossible: ce semestre n'a pas de code étape - (voir "Modifier ce semestre") + (voir "Modifier ce semestre") """ % sem ) diff --git a/app/views/notes.py b/app/views/notes.py index 8f64e5894..fce8b95a0 100644 --- a/app/views/notes.py +++ b/app/views/notes.py @@ -957,7 +957,7 @@ def edit_enseignants_form(moduleimpl_id):

Pour changer le responsable du module, passez par la page "Modification du semestre", accessible uniquement au responsable de la formation (chef de département)