diff --git a/app/scodoc/sco_formsemestre_edit.py b/app/scodoc/sco_formsemestre_edit.py index 5a776c35..399cf05d 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""" @@ -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 "Pour changer le responsable du module, passez par la page "Modification du semestre", accessible uniquement au responsable de la formation (chef de département)