1
0
forked from ScoDoc/ScoDoc

Assiduité : correction bug moduleimpls edit_assiduite_etud

This commit is contained in:
Iziram 2024-06-05 13:43:44 +02:00
parent 09f697941d
commit 7c7697631e
2 changed files with 22 additions and 8 deletions

View File

@ -405,6 +405,18 @@ class Identite(models.ScoDocModel):
modimpls_by_formsemestre[formsemestre.id] = modimpls_sem modimpls_by_formsemestre[formsemestre.id] = modimpls_sem
return modimpls_by_formsemestre return modimpls_by_formsemestre
def get_modimpls_from_formsemestre(
self, formsemestre: "FormSemestre"
) -> list["ModuleImpl"]:
"""
Liste des ModuleImpl auxquels l'étudiant est inscrit dans le formsemestre.
"""
modimpls = ModuleImpl.query.join(ModuleImplInscription).filter(
ModuleImplInscription.etudid == self.id,
ModuleImpl.formsemestre_id == formsemestre.id,
)
return modimpls.all()
@classmethod @classmethod
def convert_dict_fields(cls, args: dict) -> dict: def convert_dict_fields(cls, args: dict) -> dict:
"""Convert fields in the given dict. No other side effect. """Convert fields in the given dict. No other side effect.

View File

@ -2168,17 +2168,19 @@ def edit_assiduite_etud(assiduite_id: int):
form.disable_all() form.disable_all()
# peuplement moduleimpl_select # peuplement moduleimpl_select
modimpls_by_formsemestre = etud.get_modimpls_by_formsemestre(scu.annee_scolaire())
choices: OrderedDict = OrderedDict() choices: OrderedDict = OrderedDict()
choices[""] = [("", "Non spécifié"), ("autre", "Autre module (pas dans la liste)")] choices[""] = [("", "Non spécifié"), ("autre", "Autre module (pas dans la liste)")]
# indique le nom du semestre dans le menu (optgroup) # Récupération des modulesimpl du semestre si existant.
group_name: str = formsemestre.titre_annee() if formsemestre:
choices[group_name] = [ # indique le nom du semestre dans le menu (optgroup)
(m.id, f"{m.module.code} {m.module.abbrev or m.module.titre or ''}") modimpls_from_formsemestre = etud.get_modimpls_from_formsemestre(formsemestre)
for m in modimpls_by_formsemestre[formsemestre.id] group_name: str = formsemestre.titre_annee()
if m.module.ue.type == UE_STANDARD choices[group_name] = [
] (m.id, f"{m.module.code} {m.module.abbrev or m.module.titre or ''}")
for m in modimpls_from_formsemestre
if m.module.ue.type == UE_STANDARD
]
choices.move_to_end("", last=False) choices.move_to_end("", last=False)
form.modimpl.choices = choices form.modimpl.choices = choices