From 9413573e582e1a7647cbf2562cbabebb6febbfb9 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Mon, 9 Aug 2021 10:09:04 +0200 Subject: [PATCH] fix type: formation_id, matiere_id --- app/scodoc/pe_jurype.py | 2 +- app/scodoc/pe_tools.py | 2 +- app/scodoc/sco_edit_formation.py | 21 ++++++++++++++++++--- app/scodoc/sco_edit_matiere.py | 9 ++++++--- app/scodoc/sco_edit_module.py | 10 +++++----- app/scodoc/sco_edit_ue.py | 22 +++++++++++++++------- app/scodoc/sco_formations.py | 10 ++++++++-- 7 files changed, 54 insertions(+), 22 deletions(-) diff --git a/app/scodoc/pe_jurype.py b/app/scodoc/pe_jurype.py index 73440bb8..b5d9b9c5 100644 --- a/app/scodoc/pe_jurype.py +++ b/app/scodoc/pe_jurype.py @@ -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 = [ diff --git a/app/scodoc/pe_tools.py b/app/scodoc/pe_tools.py index fd1587d8..f119d26c 100644 --- a/app/scodoc/pe_tools.py +++ b/app/scodoc/pe_tools.py @@ -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 diff --git a/app/scodoc/sco_edit_formation.py b/app/scodoc/sco_edit_formation.py index 4f6e0123..642baa1a 100644 --- a/app/scodoc/sco_edit_formation.py +++ b/app/scodoc/sco_edit_formation.py @@ -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"]) \ No newline at end of file + return flask.redirect( + url_for( + "notes.ue_list", + scodoc_dept=g.scodoc_dept, + formation_id=o["formation_id"], + ) + ) diff --git a/app/scodoc/sco_edit_matiere.py b/app/scodoc/sco_edit_matiere.py index b3af967e..bcda2a50 100644 --- a/app/scodoc/sco_edit_matiere.py +++ b/app/scodoc/sco_edit_matiere.py @@ -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}, diff --git a/app/scodoc/sco_edit_module.py b/app/scodoc/sco_edit_module.py index f087cd1e..51f84379 100644 --- a/app/scodoc/sco_edit_module.py +++ b/app/scodoc/sco_edit_module.py @@ -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): """

Suppression du module %(titre)s (%(code)s)

""" % 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): diff --git a/app/scodoc/sco_edit_ue.py b/app/scodoc/sco_edit_ue.py index e33f82e3..13896270 100644 --- a/app/scodoc/sco_edit_ue.py +++ b/app/scodoc/sco_edit_ue.py @@ -630,8 +630,11 @@ Si vous souhaitez modifier cette formation (par exemple pour y ajouter un module context, Mat["matiere_id"] ): H.append( - '' - % Mat + f""" + """ ) 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("
  • Aucun module dans cette matière !") if editable: H.append( - 'supprimer cette matière' - % Mat + f"""supprimer cette matière + """ ) H.append("
  • ") if editable: # and ((not parcours.UE_IS_MODULE) or len(Modlist) == 0): H.append( - '
  • créer un module
  • ' - % Mat + f"""
  • créer un module
  • + """ ) H.append("") H.append("") @@ -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: diff --git a/app/scodoc/sco_formations.py b/app/scodoc/sco_formations.py index 62c17505..b3282a4a 100644 --- a/app/scodoc/sco_formations.py +++ b/app/scodoc/sco_formations.py @@ -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 \ No newline at end of file