From 72b0ed17b5b36550b5343d27e30e8b03ff206503 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sat, 3 Jun 2023 23:18:54 +0200 Subject: [PATCH] =?UTF-8?q?Tri=20parcours=20par=20numero=20et=20code;=20am?= =?UTF-8?q?=C3=A9liore=20table=20description=20semestre.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/modules.py | 2 +- app/models/ues.py | 5 ++++- app/scodoc/sco_formsemestre_status.py | 17 ++++++++++++++--- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/app/models/modules.py b/app/models/modules.py index 3c04f097f..ed155fdd2 100644 --- a/app/models/modules.py +++ b/app/models/modules.py @@ -55,7 +55,7 @@ class Module(db.Model): secondary=parcours_modules, lazy="subquery", backref=db.backref("modules", lazy=True), - order_by="ApcParcours.numero", + order_by="ApcParcours.numero, ApcParcours.code", ) app_critiques = db.relationship( diff --git a/app/models/ues.py b/app/models/ues.py index 8bbdb99e5..383f20f8f 100644 --- a/app/models/ues.py +++ b/app/models/ues.py @@ -58,7 +58,10 @@ class UniteEns(db.Model): # Une UE appartient soit à tous les parcours (tronc commun), soit à un sous-ensemble parcours = db.relationship( - ApcParcours, secondary="ue_parcours", backref=db.backref("ues", lazy=True) + ApcParcours, + secondary="ue_parcours", + backref=db.backref("ues", lazy=True), + order_by="ApcParcours.numero, ApcParcours.code", ) # relations diff --git a/app/scodoc/sco_formsemestre_status.py b/app/scodoc/sco_formsemestre_status.py index c8cb25da0..f918ebe78 100755 --- a/app/scodoc/sco_formsemestre_status.py +++ b/app/scodoc/sco_formsemestre_status.py @@ -594,6 +594,7 @@ def formsemestre_description_table( formsemestre: FormSemestre = FormSemestre.query.filter_by( id=formsemestre_id, dept_id=g.scodoc_dept_id ).first_or_404() + is_apc = formsemestre.formation.is_apc() nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre) use_ue_coefs = sco_preferences.get_preference("use_ue_coefs", formsemestre_id) parcours = codes_cursus.get_cursus_from_code(formsemestre.formation.type_parcours) @@ -607,7 +608,7 @@ def formsemestre_description_table( else: ues = formsemestre.get_ues() columns_ids += [f"ue_{ue.id}" for ue in ues] - if sco_preferences.get_preference("bul_show_ects", formsemestre_id): + if sco_preferences.get_preference("bul_show_ects", formsemestre_id) and not is_apc: columns_ids += ["ects"] columns_ids += ["Inscrits", "Responsable", "Enseignants"] if with_evals: @@ -634,6 +635,7 @@ def formsemestre_description_table( sum_coef = 0 sum_ects = 0 last_ue_id = None + formsemestre_parcours_ids = {p.id for p in formsemestre.parcours} for modimpl in formsemestre.modimpls_sorted: # Ligne UE avec ECTS: ue = modimpl.module.ue @@ -660,7 +662,7 @@ def formsemestre_description_table( ue_info[ f"_{k}_td_attrs" ] = f'style="background-color: {ue.color} !important;"' - if not formsemestre.formation.is_apc(): + if not is_apc: # n'affiche la ligne UE qu'en formation classique # car l'UE de rattachement n'a pas d'intérêt en BUT rows.append(ue_info) @@ -701,8 +703,17 @@ def formsemestre_description_table( for ue in ues: row[f"ue_{ue.id}"] = coef_dict.get(ue.id, 0.0) or "" if with_parcours: + # Intersection des parcours du module avec ceux du formsemestre row["parcours"] = ", ".join( - sorted([pa.code for pa in modimpl.module.parcours]) + [ + pa.code + for pa in ( + modimpl.module.parcours + if modimpl.module.parcours + else modimpl.formsemestre.parcours + ) + if pa.id in formsemestre_parcours_ids + ] ) rows.append(row)