fix type: formation_id, matiere_id

This commit is contained in:
Emmanuel Viennet 2021-08-09 10:09:04 +02:00
parent bcb7dc828d
commit 9413573e58
7 changed files with 54 additions and 22 deletions

View File

@ -1246,7 +1246,7 @@ def get_cosemestres_diplomants(context, semBase, avec_meme_formation=False):
diplome = get_annee_diplome_semestre(semBase)
if avec_meme_formation: # si une formation est imposee
nom_formation = semBase["formation_id"]
nom_formation = str(semBase["formation_id"])
if pe_tools.PE_DEBUG:
pe_tools.pe_print(" - avec formation imposée : ", nom_formation)
coSems = [

View File

@ -87,7 +87,7 @@ def print_semestres_description(sems, avec_affichage_debug=False):
+ sem["anneescolaire"]
)
desc += " (" + sem["annee_debut"] + "/" + sem["annee_fin"] + ") "
desc += sem["formation_id"] + " / " + sem["formsemestre_id"]
desc += str(sem["formation_id"]) + " / " + sem["formsemestre_id"]
desc += " - " + sem["titre_num"]
return desc

View File

@ -29,6 +29,7 @@
(portage from DTML)
"""
import flask
from flask import g, url_for
import app.scodoc.notesdb as ndb
import app.scodoc.sco_utils as scu
@ -251,7 +252,11 @@ def formation_edit(context, formation_id=None, create=False, REQUEST=None):
formation_id = do_formation_create(context, tf[2])
else:
do_formation_edit(context, tf[2])
return flask.redirect("ue_list?formation_id=%s" % formation_id)
return flask.redirect(
url_for(
"notes.ue_list", scodoc_dept=g.scodoc_dept, formation_id=formation_id
)
)
def do_formation_create(context, args):
@ -340,7 +345,11 @@ def module_move(context, module_id, after=0, REQUEST=None, redirect=1):
# redirect to ue_list page:
if redirect:
return flask.redirect("ue_list?formation_id=" + formation_id)
return flask.redirect(
url_for(
"notes.ue_list", scodoc_dept=g.scodoc_dept, formation_id=formation_id
)
)
def ue_move(context, ue_id, after=0, REQUEST=None, redirect=1):
@ -371,4 +380,10 @@ def ue_move(context, ue_id, after=0, REQUEST=None, redirect=1):
sco_edit_ue._ueEditor.edit(cnx, neigh)
# redirect to ue_list page
if redirect:
return flask.redirect("ue_list?formation_id=" + o["formation_id"])
return flask.redirect(
url_for(
"notes.ue_list",
scodoc_dept=g.scodoc_dept,
formation_id=o["formation_id"],
)
)

View File

@ -29,6 +29,7 @@
(portage from DTML)
"""
import flask
from flask import g, url_for
import app.scodoc.notesdb as ndb
import app.scodoc.sco_utils as scu
@ -136,7 +137,9 @@ associé.
submitlabel="Créer cette matière",
)
dest_url = scu.NotesURL() + "/ue_list?formation_id=" + UE["formation_id"]
dest_url = url_for(
"notes.ue_list", scodoc_dept=g.scodoc_dept, formation_id=UE["formation_id"]
)
if tf[0] == 0:
return "\n".join(H) + tf[1] + html_sco_header.sco_footer()
@ -283,7 +286,7 @@ associé.
submitlabel="Modifier les valeurs",
)
dest_url = scu.NotesURL() + "/ue_list?formation_id=" + U["formation_id"]
dest_url = scu.NotesURL() + "/ue_list?formation_id=" + str(U["formation_id"])
if tf[0] == 0:
return "\n".join(H) + tf[1] + help + html_sco_header.sco_footer()
@ -325,7 +328,7 @@ def matiere_is_locked(context, matiere_id):
WHERE ma.id = mod.matiere_id
AND mi.module_id = mod.id
AND mi.formsemestre_id = sem.id
AND ma.id = %(matiere_id)s
AND ma.id = %(matiere_id)s
AND sem.etat = false
""",
{"matiere_id": matiere_id},

View File

@ -125,7 +125,7 @@ def module_create(context, matiere_id=None, REQUEST=None):
from app.scodoc import sco_formations
from app.scodoc import sco_edit_ue
if not matiere_id:
if matiere_id is None:
raise ScoValueError("invalid matiere !")
M = sco_edit_matiere.do_matiere_list(context, args={"matiere_id": matiere_id})[0]
UE = sco_edit_ue.do_ue_list(context, args={"ue_id": M["ue_id"]})[0]
@ -298,7 +298,7 @@ def module_delete(context, module_id=None, REQUEST=None):
"""<h2>Suppression du module %(titre)s (%(code)s)</h2>""" % Mod,
]
dest_url = scu.NotesURL() + "/ue_list?formation_id=" + Mod["formation_id"]
dest_url = scu.NotesURL() + "/ue_list?formation_id=" + str(Mod["formation_id"])
tf = TrivialFormulator(
REQUEST.URL0,
REQUEST.form,
@ -363,7 +363,7 @@ def module_edit(context, module_id=None, REQUEST=None):
"""SELECT ue.acronyme, mat.*, mat.id AS matiere_id
FROM notes_matieres mat, notes_ue ue
WHERE mat.ue_id = ue.id
AND ue.formation_id = %(formation_id)s
AND ue.formation_id = %(formation_id)d
ORDER BY ue.numero, mat.numero
""",
{"formation_id": Mod["formation_id"]},
@ -374,7 +374,7 @@ def module_edit(context, module_id=None, REQUEST=None):
semestres_indices = list(range(1, parcours.NB_SEM + 1))
dest_url = scu.NotesURL() + "/ue_list?formation_id=" + Mod["formation_id"]
dest_url = scu.NotesURL() + "/ue_list?formation_id=" + str(Mod["formation_id"])
H = [
html_sco_header.sco_header(
@ -609,7 +609,7 @@ def formation_add_malus_modules(context, formation_id, titre=None, REQUEST=None)
ue_add_malus_module(context, ue["ue_id"], titre=titre, REQUEST=REQUEST)
if REQUEST:
return flask.redirect("ue_list?formation_id=" + formation_id)
return flask.redirect("ue_list?formation_id=" + str(formation_id))
def ue_add_malus_module(context, ue_id, titre=None, code=None, REQUEST=None):

View File

@ -630,8 +630,11 @@ Si vous souhaitez modifier cette formation (par exemple pour y ajouter un module
context, Mat["matiere_id"]
):
H.append(
'<a class="stdlink" href="matiere_edit?matiere_id=%(matiere_id)s">'
% Mat
f"""<a class="stdlink" href="{
url_for("notes.matiere_edit",
scodoc_dept=g.scodoc_dept, matiere_id=Mat["matiere_id"])
}">
"""
)
H.append("%(titre)s" % Mat)
if editable and not sco_edit_matiere.matiere_is_locked(
@ -724,14 +727,20 @@ Si vous souhaitez modifier cette formation (par exemple pour y ajouter un module
H.append("<li>Aucun module dans cette matière !")
if editable:
H.append(
'<a class="stdlink" href="matiere_delete?matiere_id=%(matiere_id)s">supprimer cette matière</a>'
% Mat
f"""<a class="stdlink" href="{
url_for("notes.matiere_delete",
scodoc_dept=g.scodoc_dept, matiere_id=Mat["matiere_id"])}"
>supprimer cette matière</a>
"""
)
H.append("</li>")
if editable: # and ((not parcours.UE_IS_MODULE) or len(Modlist) == 0):
H.append(
'<li> <a class="stdlink" href="module_create?matiere_id=%(matiere_id)s">créer un module</a></li>'
% Mat
f"""<li> <a class="stdlink" href="{
url_for("notes.module_create",
scodoc_dept=g.scodoc_dept, matiere_id=Mat["matiere_id"])}"
>créer un module</a></li>
"""
)
H.append("</ul>")
H.append("</li>")
@ -831,7 +840,6 @@ def ue_sharing_code(context, ue_code=None, ue_id=None, hide_ue_id=None):
"""
from app.scodoc import sco_formations
stop
if ue_id:
ue = do_ue_list(context, args={"ue_id": ue_id})[0]
if not ue_code:

View File

@ -31,6 +31,7 @@ from operator import itemgetter
import xml.dom.minidom
import flask
from flask import g, url_for
import app.scodoc.sco_utils as scu
@ -85,7 +86,7 @@ def formation_list(context, formation_id=None, args={}):
def formation_has_locked_sems(context, formation_id):
"True if there is a locked formsemestre in this formation"
sems = sco_formsemestre.do_formsemestre_list(
context, args={"formation_id": formation_id, "etat": "0"}
context, args={"formation_id": formation_id, "etat": False}
)
return sems
@ -362,7 +363,12 @@ def formation_create_new_version(context, formation_id, redirect=True, REQUEST=N
)
if redirect:
return flask.redirect(
"ue_list?formation_id=" + new_id + "&msg=Nouvelle version !"
url_for(
"notes.ue_list",
scodoc_dept=g.scodoc_dept,
formation_id=new_id,
msg="Nouvelle version !",
)
)
else:
return new_id, modules_old2new, ues_old2new