Minor code tweak: ue sort keys

This commit is contained in:
Emmanuel Viennet 2024-09-08 23:52:32 +02:00
parent faf09af63c
commit bc3427702e
5 changed files with 28 additions and 19 deletions

View File

@ -1108,7 +1108,7 @@ def list_ue_parcour_etud(
ues = ( ues = (
formsemestre.formation.query_ues_parcour(parcour) formsemestre.formation.query_ues_parcour(parcour)
.filter(UniteEns.semestre_idx == formsemestre.semestre_id) .filter(UniteEns.semestre_idx == formsemestre.semestre_id)
.order_by(UniteEns.numero) .order_by(UniteEns.numero, UniteEns.acronyme)
.all() .all()
) )
return [ue for ue in ues if (etud.id, ue.id) not in res.dispense_ues] return [ue for ue in ues if (etud.id, ue.id) not in res.dispense_ues]

View File

@ -95,7 +95,7 @@ class ValidationsSemestre(ResultatsCache):
for decision in ( for decision in (
decisions_jury_q.filter(db.text("ue_id is not NULL")) decisions_jury_q.filter(db.text("ue_id is not NULL"))
.join(UniteEns) .join(UniteEns)
.order_by(UniteEns.numero) .order_by(UniteEns.numero, UniteEns.acronyme)
): ):
if decision.etudid not in decisions_jury_ues: if decision.etudid not in decisions_jury_ues:
decisions_jury_ues[decision.etudid] = {} decisions_jury_ues[decision.etudid] = {}

View File

@ -471,7 +471,7 @@ class FormSemestre(models.ScoDocModel):
) )
if not with_sport: if not with_sport:
sem_ues = sem_ues.filter(UniteEns.type != codes_cursus.UE_SPORT) sem_ues = sem_ues.filter(UniteEns.type != codes_cursus.UE_SPORT)
ues = sem_ues.order_by(UniteEns.numero).all() ues = sem_ues.order_by(UniteEns.numero, UniteEns.acronyme).all()
_cache[key] = ues _cache[key] = ues
return ues return ues
@ -1347,14 +1347,14 @@ class FormSemestre(models.ScoDocModel):
etudid=etudid, formsemestre_id=self.id etudid=etudid, formsemestre_id=self.id
) )
.join(UniteEns) .join(UniteEns)
.order_by(UniteEns.numero) .order_by(UniteEns.numero, UniteEns.acronyme)
.all() .all()
) )
# Validations BUT: # Validations BUT:
vals_rcues = ( vals_rcues = (
ApcValidationRCUE.query.filter_by(etudid=etudid, formsemestre_id=self.id) ApcValidationRCUE.query.filter_by(etudid=etudid, formsemestre_id=self.id)
.join(UniteEns, ApcValidationRCUE.ue1) .join(UniteEns, ApcValidationRCUE.ue1)
.order_by(UniteEns.numero) .order_by(UniteEns.numero, UniteEns.acronyme)
.all() .all()
) )
vals_annee = ( # issues de cette année scolaire seulement vals_annee = ( # issues de cette année scolaire seulement

View File

@ -386,7 +386,7 @@ class Module(models.ScoDocModel):
ues = ( ues = (
self.formation.ues.filter_by(semestre_idx=self.ue.semestre_idx) self.formation.ues.filter_by(semestre_idx=self.ue.semestre_idx)
.filter(UniteEns.type != UE_SPORT) .filter(UniteEns.type != UE_SPORT)
.order_by(UniteEns.numero) .order_by(UniteEns.numero, UniteEns.acronyme)
.all() .all()
) )
if not ues: if not ues:

View File

@ -1332,19 +1332,7 @@ def _get_etud_ue_validations_html(etud: Identite, formsemestre: FormSemestre) ->
"""HTML listant les validations d'UEs pour cet étudiant dans des formations de même """HTML listant les validations d'UEs pour cet étudiant dans des formations de même
code que celle du formsemestre indiqué. code que celle du formsemestre indiqué.
""" """
validations: list[ScolarFormSemestreValidation] = ( validations = get_etud_ue_validations(etud, formsemestre.formation)
ScolarFormSemestreValidation.query.filter_by(etudid=etud.id)
.join(UniteEns)
.join(Formation)
.filter_by(formation_code=formsemestre.formation.formation_code)
.order_by(
sa.desc(UniteEns.semestre_idx),
UniteEns.acronyme,
sa.desc(ScolarFormSemestreValidation.event_date),
)
.all()
)
if not validations: if not validations:
return "" return ""
return render_template( return render_template(
@ -1356,6 +1344,27 @@ def _get_etud_ue_validations_html(etud: Identite, formsemestre: FormSemestre) ->
) )
def get_etud_ue_validations(
etud: Identite, formation: Formation
) -> list[ScolarFormSemestreValidation]:
"""Retourne les validations d'UEs pour cet étudiant dans des formations de même
code que celle indiquée.
"""
return (
ScolarFormSemestreValidation.query.filter_by(etudid=etud.id)
.join(UniteEns)
.join(Formation)
.filter_by(formation_code=formation.formation_code)
.order_by(
sa.desc(UniteEns.semestre_idx),
UniteEns.numero,
UniteEns.acronyme,
sa.desc(ScolarFormSemestreValidation.event_date),
)
.all()
)
def do_formsemestre_validate_previous_ue( def do_formsemestre_validate_previous_ue(
formsemestre: FormSemestre, formsemestre: FormSemestre,
etudid, etudid,