From c332f1cee7ea2ac7cf087347dcab1da810854d7d Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Fri, 10 Dec 2021 01:55:13 +0100 Subject: [PATCH] ordre des UE (et coefs) --- app/models/formsemestre.py | 2 +- app/models/modules.py | 8 +++++++- app/templates/formsemestre_header.html | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/models/formsemestre.py b/app/models/formsemestre.py index a35f511c7..f564a41bd 100644 --- a/app/models/formsemestre.py +++ b/app/models/formsemestre.py @@ -137,7 +137,7 @@ class FormSemestre(db.Model): ) if not with_sport: sem_ues = sem_ues.filter(UniteEns.type != sco_codes_parcours.UE_SPORT) - return sem_ues + return sem_ues.order_by(UniteEns.numero) def est_courant(self) -> bool: """Vrai si la date actuelle (now) est dans le semestre diff --git a/app/models/modules.py b/app/models/modules.py index e19c77748..f5a978c2d 100644 --- a/app/models/modules.py +++ b/app/models/modules.py @@ -111,9 +111,15 @@ class Module(db.Model): db.session.delete(ue_coef) self.formation.invalidate_module_coefs() + def get_ue_coefs_sorted(self): + "les coefs d'UE, trié par numéro d'UE" + # je n'ai pas su mettre un order_by sur le backref sans avoir + # à redéfinir les relationships... + return sorted(self.ue_coefs, key=lambda x: x.ue.numero) + def ue_coefs_descr(self): """List of tuples [ (ue_acronyme, coef) ]""" - return [(c.ue.acronyme, c.coef) for c in self.ue_coefs] + return [(c.ue.acronyme, c.coef) for c in self.get_ue_coefs_sorted()] class ModuleUECoef(db.Model): diff --git a/app/templates/formsemestre_header.html b/app/templates/formsemestre_header.html index bb68e5136..441a32872 100644 --- a/app/templates/formsemestre_header.html +++ b/app/templates/formsemestre_header.html @@ -20,11 +20,11 @@ title="{{sco.sem.responsables_str(abbrev_prenom=False)}}">{{sco.sem.responsables_str()}} {{sco.sem.inscriptions|length}} inscrits{% if - sco.sem.etat %}{{sco.scu.icontag("lock_img", border="0", title="Semestre verrouillé")|safe}}{% endif %} {% if sco.prefs["bul_display_publication"] %} - {% if sco.sem.bul_hide_xml %} {{ sco.scu.icontag("hide_img", border="0", title="Bulletins NON publiés")|safe}}