forked from ScoDoc/ScoDoc
Assiduite : ordre options select module
This commit is contained in:
parent
c620c3b0e1
commit
3184d5d92e
@ -28,6 +28,8 @@ import datetime
|
|||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
from collections import OrderedDict
|
||||||
|
|
||||||
from flask import g, request, render_template, flash
|
from flask import g, request, render_template, flash
|
||||||
from flask import abort, url_for, redirect, Response
|
from flask import abort, url_for, redirect, Response
|
||||||
from flask_login import current_user
|
from flask_login import current_user
|
||||||
@ -229,17 +231,22 @@ def ajout_assiduite_etud() -> str | Response:
|
|||||||
# On dresse la liste des modules de l'année scolaire en cours
|
# On dresse la liste des modules de l'année scolaire en cours
|
||||||
# auxquels est inscrit l'étudiant pour peupler le menu "module"
|
# auxquels est inscrit l'étudiant pour peupler le menu "module"
|
||||||
modimpls_by_formsemestre = etud.get_modimpls_by_formsemestre(scu.annee_scolaire())
|
modimpls_by_formsemestre = etud.get_modimpls_by_formsemestre(scu.annee_scolaire())
|
||||||
choices = {
|
choices: OrderedDict = OrderedDict()
|
||||||
"": [("", "Non spécifié"), ("autre", "Autre module (pas dans la liste)")]
|
choices[""] = [("", "Non spécifié"), ("autre", "Autre module (pas dans la liste)")]
|
||||||
}
|
|
||||||
for formsemestre_id in modimpls_by_formsemestre:
|
for formsemestre_id in modimpls_by_formsemestre:
|
||||||
formsemestre: FormSemestre = FormSemestre.query.get(formsemestre_id)
|
formsemestre: FormSemestre = FormSemestre.query.get(formsemestre_id)
|
||||||
|
|
||||||
# indique le nom du semestre dans le menu (optgroup)
|
# indique le nom du semestre dans le menu (optgroup)
|
||||||
choices[formsemestre.titre_annee()] = [
|
group_name: str = formsemestre.titre_annee()
|
||||||
|
choices[group_name] = [
|
||||||
(m.id, f"{m.module.code} {m.module.abbrev or m.module.titre or ''}")
|
(m.id, f"{m.module.code} {m.module.abbrev or m.module.titre or ''}")
|
||||||
for m in modimpls_by_formsemestre[formsemestre_id]
|
for m in modimpls_by_formsemestre[formsemestre_id]
|
||||||
if m.module.ue.type == UE_STANDARD
|
if m.module.ue.type == UE_STANDARD
|
||||||
]
|
]
|
||||||
|
|
||||||
|
if formsemestre.est_courant():
|
||||||
|
choices.move_to_end(group_name, last=False)
|
||||||
|
choices.move_to_end("", last=False)
|
||||||
form.modimpl.choices = choices
|
form.modimpl.choices = choices
|
||||||
|
|
||||||
if form.validate_on_submit():
|
if form.validate_on_submit():
|
||||||
@ -2150,7 +2157,7 @@ def _module_selector_multiple(
|
|||||||
Prend les semestres de l'année, sauf si only_form est indiqué.
|
Prend les semestres de l'année, sauf si only_form est indiqué.
|
||||||
"""
|
"""
|
||||||
modimpls_by_formsemestre = etud.get_modimpls_by_formsemestre(scu.annee_scolaire())
|
modimpls_by_formsemestre = etud.get_modimpls_by_formsemestre(scu.annee_scolaire())
|
||||||
choices = {}
|
choices = OrderedDict()
|
||||||
for formsemestre_id in modimpls_by_formsemestre:
|
for formsemestre_id in modimpls_by_formsemestre:
|
||||||
formsemestre: FormSemestre = FormSemestre.query.get(formsemestre_id)
|
formsemestre: FormSemestre = FormSemestre.query.get(formsemestre_id)
|
||||||
if only_form is not None and formsemestre != only_form:
|
if only_form is not None and formsemestre != only_form:
|
||||||
@ -2165,6 +2172,9 @@ def _module_selector_multiple(
|
|||||||
if m.module.ue.type == UE_STANDARD
|
if m.module.ue.type == UE_STANDARD
|
||||||
]
|
]
|
||||||
|
|
||||||
|
if formsemestre.est_courant():
|
||||||
|
choices.move_to_end(formsemestre.titre_annee(), last=False)
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
"assiduites/widgets/moduleimpl_selector_multiple.j2",
|
"assiduites/widgets/moduleimpl_selector_multiple.j2",
|
||||||
choices=choices,
|
choices=choices,
|
||||||
|
Loading…
Reference in New Issue
Block a user