1
0
forked from ScoDoc/ScoDoc

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) diplome = get_annee_diplome_semestre(semBase)
if avec_meme_formation: # si une formation est imposee 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: if pe_tools.PE_DEBUG:
pe_tools.pe_print(" - avec formation imposée : ", nom_formation) pe_tools.pe_print(" - avec formation imposée : ", nom_formation)
coSems = [ coSems = [

View File

@ -87,7 +87,7 @@ def print_semestres_description(sems, avec_affichage_debug=False):
+ sem["anneescolaire"] + sem["anneescolaire"]
) )
desc += " (" + sem["annee_debut"] + "/" + sem["annee_fin"] + ") " 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"] desc += " - " + sem["titre_num"]
return desc return desc

View File

@ -29,6 +29,7 @@
(portage from DTML) (portage from DTML)
""" """
import flask import flask
from flask import g, url_for
import app.scodoc.notesdb as ndb import app.scodoc.notesdb as ndb
import app.scodoc.sco_utils as scu 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]) formation_id = do_formation_create(context, tf[2])
else: else:
do_formation_edit(context, tf[2]) 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): 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: # redirect to ue_list page:
if redirect: 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): 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) sco_edit_ue._ueEditor.edit(cnx, neigh)
# redirect to ue_list page # redirect to ue_list page
if redirect: 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) (portage from DTML)
""" """
import flask import flask
from flask import g, url_for
import app.scodoc.notesdb as ndb import app.scodoc.notesdb as ndb
import app.scodoc.sco_utils as scu import app.scodoc.sco_utils as scu
@ -136,7 +137,9 @@ associé.
submitlabel="Créer cette matière", 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: if tf[0] == 0:
return "\n".join(H) + tf[1] + html_sco_header.sco_footer() return "\n".join(H) + tf[1] + html_sco_header.sco_footer()
@ -283,7 +286,7 @@ associé.
submitlabel="Modifier les valeurs", 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: if tf[0] == 0:
return "\n".join(H) + tf[1] + help + html_sco_header.sco_footer() return "\n".join(H) + tf[1] + help + html_sco_header.sco_footer()

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_formations
from app.scodoc import sco_edit_ue from app.scodoc import sco_edit_ue
if not matiere_id: if matiere_id is None:
raise ScoValueError("invalid matiere !") raise ScoValueError("invalid matiere !")
M = sco_edit_matiere.do_matiere_list(context, args={"matiere_id": matiere_id})[0] 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] 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, """<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( tf = TrivialFormulator(
REQUEST.URL0, REQUEST.URL0,
REQUEST.form, REQUEST.form,
@ -363,7 +363,7 @@ def module_edit(context, module_id=None, REQUEST=None):
"""SELECT ue.acronyme, mat.*, mat.id AS matiere_id """SELECT ue.acronyme, mat.*, mat.id AS matiere_id
FROM notes_matieres mat, notes_ue ue FROM notes_matieres mat, notes_ue ue
WHERE mat.ue_id = ue.id 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 ORDER BY ue.numero, mat.numero
""", """,
{"formation_id": Mod["formation_id"]}, {"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)) 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 = [ H = [
html_sco_header.sco_header( 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) ue_add_malus_module(context, ue["ue_id"], titre=titre, REQUEST=REQUEST)
if 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): 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"] context, Mat["matiere_id"]
): ):
H.append( H.append(
'<a class="stdlink" href="matiere_edit?matiere_id=%(matiere_id)s">' f"""<a class="stdlink" href="{
% Mat url_for("notes.matiere_edit",
scodoc_dept=g.scodoc_dept, matiere_id=Mat["matiere_id"])
}">
"""
) )
H.append("%(titre)s" % Mat) H.append("%(titre)s" % Mat)
if editable and not sco_edit_matiere.matiere_is_locked( 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 !") H.append("<li>Aucun module dans cette matière !")
if editable: if editable:
H.append( H.append(
'<a class="stdlink" href="matiere_delete?matiere_id=%(matiere_id)s">supprimer cette matière</a>' f"""<a class="stdlink" href="{
% Mat url_for("notes.matiere_delete",
scodoc_dept=g.scodoc_dept, matiere_id=Mat["matiere_id"])}"
>supprimer cette matière</a>
"""
) )
H.append("</li>") H.append("</li>")
if editable: # and ((not parcours.UE_IS_MODULE) or len(Modlist) == 0): if editable: # and ((not parcours.UE_IS_MODULE) or len(Modlist) == 0):
H.append( H.append(
'<li> <a class="stdlink" href="module_create?matiere_id=%(matiere_id)s">créer un module</a></li>' f"""<li> <a class="stdlink" href="{
% Mat 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("</ul>")
H.append("</li>") 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 from app.scodoc import sco_formations
stop
if ue_id: if ue_id:
ue = do_ue_list(context, args={"ue_id": ue_id})[0] ue = do_ue_list(context, args={"ue_id": ue_id})[0]
if not ue_code: if not ue_code:

View File

@ -31,6 +31,7 @@ from operator import itemgetter
import xml.dom.minidom import xml.dom.minidom
import flask import flask
from flask import g, url_for
import app.scodoc.sco_utils as scu 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): def formation_has_locked_sems(context, formation_id):
"True if there is a locked formsemestre in this formation" "True if there is a locked formsemestre in this formation"
sems = sco_formsemestre.do_formsemestre_list( sems = sco_formsemestre.do_formsemestre_list(
context, args={"formation_id": formation_id, "etat": "0"} context, args={"formation_id": formation_id, "etat": False}
) )
return sems return sems
@ -362,7 +363,12 @@ def formation_create_new_version(context, formation_id, redirect=True, REQUEST=N
) )
if redirect: if redirect:
return flask.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: else:
return new_id, modules_old2new, ues_old2new return new_id, modules_old2new, ues_old2new