forked from ScoDoc/DocScoDoc
Fix regression on ue_list
This commit is contained in:
parent
0f67ee33ae
commit
c49aecaa2f
@ -588,9 +588,9 @@ def formation_add_malus_modules(formation_id, titre=None, redirect=True):
|
||||
"""Création d'un module de "malus" dans chaque UE d'une formation"""
|
||||
from app.scodoc import sco_edit_ue
|
||||
|
||||
ue_list = sco_edit_ue.ue_list(args={"formation_id": formation_id})
|
||||
ues = sco_edit_ue.ue_list(args={"formation_id": formation_id})
|
||||
|
||||
for ue in ue_list:
|
||||
for ue in ues:
|
||||
# Un seul module de malus par UE:
|
||||
nb_mod_malus = len(
|
||||
[
|
||||
@ -603,7 +603,11 @@ def formation_add_malus_modules(formation_id, titre=None, redirect=True):
|
||||
ue_add_malus_module(ue["ue_id"], titre=titre)
|
||||
|
||||
if redirect:
|
||||
return flask.redirect("ue_list?formation_id=" + str(formation_id))
|
||||
return flask.redirect(
|
||||
url_for(
|
||||
"notes.ue_table", scodoc_dept=g.scodoc_dept, formation_id=formation_id
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def ue_add_malus_module(ue_id, titre=None, code=None):
|
||||
|
@ -374,12 +374,12 @@ def ue_edit(ue_id=None, create=False, formation_id=None):
|
||||
)
|
||||
|
||||
|
||||
def _add_ue_semestre_id(ue_list):
|
||||
def _add_ue_semestre_id(ues):
|
||||
"""ajoute semestre_id dans les ue, en regardant le premier module de chacune.
|
||||
Les UE sans modules se voient attribuer le numero UE_SEM_DEFAULT (1000000),
|
||||
qui les place à la fin de la liste.
|
||||
"""
|
||||
for ue in ue_list:
|
||||
for ue in ues:
|
||||
Modlist = sco_edit_module.module_list(args={"ue_id": ue["ue_id"]})
|
||||
if Modlist:
|
||||
ue["semestre_id"] = Modlist[0]["semestre_id"]
|
||||
@ -391,27 +391,27 @@ def next_ue_numero(formation_id, semestre_id=None):
|
||||
"""Numero d'une nouvelle UE dans cette formation.
|
||||
Si le semestre est specifie, cherche les UE ayant des modules de ce semestre
|
||||
"""
|
||||
ue_list = ue_list(args={"formation_id": formation_id})
|
||||
if not ue_list:
|
||||
ues = ue_list(args={"formation_id": formation_id})
|
||||
if not ues:
|
||||
return 0
|
||||
if semestre_id is None:
|
||||
return ue_list[-1]["numero"] + 1000
|
||||
return ues[-1]["numero"] + 1000
|
||||
else:
|
||||
# Avec semestre: (prend le semestre du 1er module de l'UE)
|
||||
_add_ue_semestre_id(ue_list)
|
||||
ue_list_semestre = [ue for ue in ue_list if ue["semestre_id"] == semestre_id]
|
||||
_add_ue_semestre_id(ues)
|
||||
ue_list_semestre = [ue for ue in ues if ue["semestre_id"] == semestre_id]
|
||||
if ue_list_semestre:
|
||||
return ue_list_semestre[-1]["numero"] + 10
|
||||
else:
|
||||
return ue_list[-1]["numero"] + 1000
|
||||
return ues[-1]["numero"] + 1000
|
||||
|
||||
|
||||
def ue_delete(ue_id=None, delete_validations=False, dialog_confirmed=False):
|
||||
"""Delete an UE"""
|
||||
ue = ue_list(args={"ue_id": ue_id})
|
||||
if not ue:
|
||||
ues = ue_list(args={"ue_id": ue_id})
|
||||
if not ues:
|
||||
raise ScoValueError("UE inexistante !")
|
||||
ue = ue[0]
|
||||
ue = ues[0]
|
||||
|
||||
if not dialog_confirmed:
|
||||
return scu.confirm_dialog(
|
||||
@ -438,11 +438,11 @@ def ue_table(formation_id=None, msg=""): # was ue_list
|
||||
parcours = sco_codes_parcours.get_parcours_from_code(F["type_parcours"])
|
||||
locked = sco_formations.formation_has_locked_sems(formation_id)
|
||||
|
||||
ue_list = ue_list(args={"formation_id": formation_id})
|
||||
ues = ue_list(args={"formation_id": formation_id})
|
||||
# tri par semestre et numero:
|
||||
_add_ue_semestre_id(ue_list)
|
||||
ue_list.sort(key=lambda u: (u["semestre_id"], u["numero"]))
|
||||
has_duplicate_ue_codes = len(set([ue["ue_code"] for ue in ue_list])) != len(ue_list)
|
||||
_add_ue_semestre_id(ues)
|
||||
ues.sort(key=lambda u: (u["semestre_id"], u["numero"]))
|
||||
has_duplicate_ue_codes = len(set([ue["ue_code"] for ue in ues])) != len(ues)
|
||||
|
||||
perm_change = current_user.has_permission(Permission.ScoChangeFormation)
|
||||
# editable = (not locked) and perm_change
|
||||
@ -559,7 +559,7 @@ du programme" (menu "Semestre") si vous avez un semestre en cours);
|
||||
|
||||
cur_ue_semestre_id = None
|
||||
iue = 0
|
||||
for UE in ue_list:
|
||||
for UE in ues:
|
||||
if UE["ects"]:
|
||||
UE["ects_str"] = ", %g ECTS" % UE["ects"]
|
||||
else:
|
||||
@ -593,7 +593,7 @@ du programme" (menu "Semestre") si vous avez un semestre en cours);
|
||||
)
|
||||
else:
|
||||
H.append(arrow_none)
|
||||
if iue < len(ue_list) - 1 and editable:
|
||||
if iue < len(ues) - 1 and editable:
|
||||
H.append(
|
||||
'<a href="ue_move?ue_id=%s&after=1" class="aud">%s</a>'
|
||||
% (UE["ue_id"], arrow_down)
|
||||
@ -964,9 +964,9 @@ def formation_table_recap(formation_id, format="html"):
|
||||
raise ScoValueError("invalid formation_id")
|
||||
F = F[0]
|
||||
T = []
|
||||
ue_list = ue_list(args={"formation_id": formation_id})
|
||||
for UE in ue_list:
|
||||
Matlist = sco_edit_matiere.matiere_list(args={"ue_id": UE["ue_id"]})
|
||||
ues = ue_list(args={"formation_id": formation_id})
|
||||
for ue in ues:
|
||||
Matlist = sco_edit_matiere.matiere_list(args={"ue_id": ue["ue_id"]})
|
||||
for Mat in Matlist:
|
||||
Modlist = sco_edit_module.module_list(
|
||||
args={"matiere_id": Mat["matiere_id"]}
|
||||
@ -978,7 +978,7 @@ def formation_table_recap(formation_id, format="html"):
|
||||
#
|
||||
T.append(
|
||||
{
|
||||
"UE_acro": UE["acronyme"],
|
||||
"UE_acro": ue["acronyme"],
|
||||
"Mat_tit": Mat["titre"],
|
||||
"Mod_tit": Mod["abbrev"] or Mod["titre"],
|
||||
"Mod_code": Mod["code"],
|
||||
|
@ -334,7 +334,17 @@ sco_publish(
|
||||
Permission.ScoChangeFormation,
|
||||
methods=["GET", "POST"],
|
||||
)
|
||||
sco_publish("/ue_list", sco_edit_ue.ue_table, Permission.ScoView)
|
||||
|
||||
|
||||
@bp.route("/ue_table")
|
||||
@bp.route("/ue_list") # backward compat
|
||||
@scodoc
|
||||
@permission_required(Permission.ScoView)
|
||||
@scodoc7func
|
||||
def ue_table(formation_id=None, msg=""):
|
||||
return sco_edit_ue.ue_table(formation_id=formation_id, msg=msg)
|
||||
|
||||
|
||||
sco_publish("/ue_sharing_code", sco_edit_ue.ue_sharing_code, Permission.ScoView)
|
||||
sco_publish(
|
||||
"/edit_ue_set_code_apogee",
|
||||
|
Loading…
Reference in New Issue
Block a user