This commit is contained in:
Emmanuel Viennet 2023-01-13 20:05:39 -03:00
parent 6c850d2665
commit fef9b70eaf
3 changed files with 20 additions and 12 deletions

View File

@ -28,7 +28,7 @@
"""Form choix modules / responsables et creation formsemestre """Form choix modules / responsables et creation formsemestre
""" """
import flask import flask
from flask import url_for, flash from flask import url_for, flash, redirect
from flask import g, request from flask import g, request
from flask_login import current_user 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() uid2display[u.id] = u.get_nomplogin()
allowed_user_names = list(uid2display.values()) + [""] allowed_user_names = list(uid2display.values()) + [""]
# #
formation_id = int(vals["formation_id"]) if formsemestre:
formation = Formation.query.get(formation_id) formation = formsemestre.formation
if formation is None: else:
raise ScoValueError("Formation inexistante !") formation_id = int(vals["formation_id"])
formation = Formation.query.get_or_404(formation_id)
is_apc = formation.is_apc() is_apc = formation.is_apc()
if not edit: if not edit:
initvalues = {"titre": _default_sem_title(formation)} initvalues = {"titre": _default_sem_title(formation)}
@ -236,7 +238,7 @@ def do_formsemestre_createwithmodules(edit=False, formsemestre: FormSemestre = N
else: else:
modules = ( modules = (
Module.query.filter( 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) .order_by(Module.module_type, UniteEns.numero, Module.numero)
.all() .all()
@ -254,7 +256,7 @@ def do_formsemestre_createwithmodules(edit=False, formsemestre: FormSemestre = N
# #
modform = [ modform = [
("formsemestre_id", {"input_type": "hidden"}), ("formsemestre_id", {"input_type": "hidden"}),
("formation_id", {"input_type": "hidden", "default": formation_id}), ("formation_id", {"input_type": "hidden", "default": formation.id}),
( (
"date_debut", "date_debut",
{ {
@ -435,7 +437,7 @@ def do_formsemestre_createwithmodules(edit=False, formsemestre: FormSemestre = N
) )
if edit: if edit:
formtit = f""" formtit = f"""
<p><a href="{url_for("notes.formsemestre_edit_uecoefs", <p><a class="stdlink" href="{url_for("notes.formsemestre_edit_uecoefs",
scodoc_dept=g.scodoc_dept, formsemestre_id=formsemestre.id) scodoc_dept=g.scodoc_dept, formsemestre_id=formsemestre.id)
}">Modifier les coefficients des UE capitalisées</a> }">Modifier les coefficients des UE capitalisées</a>
</p> </p>
@ -772,7 +774,7 @@ def do_formsemestre_createwithmodules(edit=False, formsemestre: FormSemestre = N
if tf[0] == 0 or msg: if tf[0] == 0 or msg:
return f"""<p>Formation <a class="discretelink" href="{ return f"""<p>Formation <a class="discretelink" href="{
url_for("notes.ue_table", scodoc_dept=g.scodoc_dept, url_for("notes.ue_table", scodoc_dept=g.scodoc_dept,
formation_id=formation_id) formation_id=formation.id)
}"><em>{formation.titre}</em> ({formation.acronyme}), version { }"><em>{formation.titre}</em> ({formation.acronyme}), version {
formation.version}, code {formation.formation_code}</a> formation.version}, code {formation.formation_code}</a>
</p> </p>
@ -1769,7 +1771,13 @@ def formsemestre_edit_uecoefs(formsemestre_id, err_ue_id=None):
if tf[0] == 0: if tf[0] == 0:
return "\n".join(H) + tf[1] + footer return "\n".join(H) + tf[1] + footer
elif tf[0] == -1: elif tf[0] == -1:
return "<h4>annulation</h4>" return redirect(
url_for(
"notes.formsemestre_editwithmodules",
scodoc_dept=g.scodoc_dept,
formsemestre_id=formsemestre_id,
)
)
else: else:
# change values # change values
# 1- supprime les coef qui ne sont plus forcés # 1- supprime les coef qui ne sont plus forcés

View File

@ -102,7 +102,7 @@ def formsemestre_synchro_etuds(
if not sem["etapes"]: if not sem["etapes"]:
raise ScoValueError( raise ScoValueError(
"""opération impossible: ce semestre n'a pas de code étape """opération impossible: ce semestre n'a pas de code étape
(voir "<a href="formsemestre_editwithmodules?formation_id=%(formation_id)s&formsemestre_id=%(formsemestre_id)s">Modifier ce semestre</a>") (voir "<a href="formsemestre_editwithmodules?formsemestre_id=%(formsemestre_id)s">Modifier ce semestre</a>")
""" """
% sem % sem
) )

View File

@ -957,7 +957,7 @@ def edit_enseignants_form(moduleimpl_id):
<p class="help">Pour changer le responsable du module, passez par la <p class="help">Pour changer le responsable du module, passez par la
page "<a class="stdlink" href="{ page "<a class="stdlink" href="{
url_for("notes.formsemestre_editwithmodules", scodoc_dept=g.scodoc_dept, url_for("notes.formsemestre_editwithmodules", scodoc_dept=g.scodoc_dept,
formation_id=sem["formation_id"], formsemestre_id=M["formsemestre_id"]) formsemestre_id=M["formsemestre_id"])
}">Modification du semestre</a>", }">Modification du semestre</a>",
accessible uniquement au responsable de la formation (chef de département) accessible uniquement au responsable de la formation (chef de département)
</p> </p>