forked from ScoDoc/ScoDoc
Update opolka/ScoDoc from ScoDoc/ScoDoc #2
@ -28,6 +28,8 @@ import datetime
|
||||
import json
|
||||
import re
|
||||
|
||||
from collections import OrderedDict
|
||||
|
||||
from flask import g, request, render_template, flash
|
||||
from flask import abort, url_for, redirect, Response
|
||||
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
|
||||
# auxquels est inscrit l'étudiant pour peupler le menu "module"
|
||||
modimpls_by_formsemestre = etud.get_modimpls_by_formsemestre(scu.annee_scolaire())
|
||||
choices = {
|
||||
"": [("", "Non spécifié"), ("autre", "Autre module (pas dans la liste)")]
|
||||
}
|
||||
choices: OrderedDict = OrderedDict()
|
||||
choices[""] = [("", "Non spécifié"), ("autre", "Autre module (pas dans la liste)")]
|
||||
for formsemestre_id in modimpls_by_formsemestre:
|
||||
formsemestre: FormSemestre = FormSemestre.query.get(formsemestre_id)
|
||||
|
||||
# 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 ''}")
|
||||
for m in modimpls_by_formsemestre[formsemestre_id]
|
||||
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
|
||||
|
||||
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é.
|
||||
"""
|
||||
modimpls_by_formsemestre = etud.get_modimpls_by_formsemestre(scu.annee_scolaire())
|
||||
choices = {}
|
||||
choices = OrderedDict()
|
||||
for formsemestre_id in modimpls_by_formsemestre:
|
||||
formsemestre: FormSemestre = FormSemestre.query.get(formsemestre_id)
|
||||
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 formsemestre.est_courant():
|
||||
choices.move_to_end(formsemestre.titre_annee(), last=False)
|
||||
|
||||
return render_template(
|
||||
"assiduites/widgets/moduleimpl_selector_multiple.j2",
|
||||
choices=choices,
|
||||
|
Loading…
Reference in New Issue
Block a user