1
0
forked from ScoDoc/ScoDoc

Fix ordre colonnes res/sae dans tableau recap.

This commit is contained in:
Emmanuel Viennet 2023-01-14 14:01:54 -03:00 committed by iziram
parent 5753ac92f4
commit 6833a28274
6 changed files with 34 additions and 16 deletions

View File

@ -494,7 +494,7 @@ class ResultatsSemestre(ResultatsCache):
classes: str = "", classes: str = "",
idx: int = 100, idx: int = 100,
): ):
"Add a row to our table. classes is a list of css class names" "Add a cell to our table. classes is a list of css class names"
row[col_id] = content row[col_id] = content
if classes: if classes:
row[f"_{col_id}_class"] = classes + f" c{idx}" row[f"_{col_id}_class"] = classes + f" c{idx}"
@ -569,7 +569,8 @@ class ResultatsSemestre(ResultatsCache):
) )
# --- Moyenne d'UE # --- Moyenne d'UE
nb_ues_validables, nb_ues_warning = 0, 0 nb_ues_validables, nb_ues_warning = 0, 0
for ue in ues_sans_bonus: idx_ue_start = idx
for idx_ue, ue in enumerate(ues_sans_bonus):
ue_status = self.get_etud_ue_status(etudid, ue.id) ue_status = self.get_etud_ue_status(etudid, ue.id)
if ue_status is not None: if ue_status is not None:
col_id = f"moy_ue_{ue.id}" col_id = f"moy_ue_{ue.id}"
@ -590,7 +591,7 @@ class ResultatsSemestre(ResultatsCache):
ue.acronyme, ue.acronyme,
fmt_note(val), fmt_note(val),
"col_ue" + note_class, "col_ue" + note_class,
idx, idx_ue * 10000 + idx_ue_start,
) )
titles_bot[ titles_bot[
f"_{col_id}_target_attrs" f"_{col_id}_target_attrs"
@ -611,7 +612,7 @@ class ResultatsSemestre(ResultatsCache):
f"Bonus {ue.acronyme}", f"Bonus {ue.acronyme}",
val_fmt_html if allow_html else val_fmt, val_fmt_html if allow_html else val_fmt,
"col_ue_bonus", "col_ue_bonus",
idx, idx_ue * 10000 + idx_ue_start + 1,
) )
row[f"_bonus_ue_{ue.id}_xls"] = val_fmt row[f"_bonus_ue_{ue.id}_xls"] = val_fmt
# Les moyennes des modules (ou ressources et SAÉs) dans cette UE # Les moyennes des modules (ou ressources et SAÉs) dans cette UE
@ -656,7 +657,11 @@ class ResultatsSemestre(ResultatsCache):
val_fmt_html, val_fmt_html,
# class col_res mod_ue_123 # class col_res mod_ue_123
f"col_{modimpl.module.type_abbrv()} mod_ue_{ue.id}", f"col_{modimpl.module.type_abbrv()} mod_ue_{ue.id}",
idx, idx_ue * 10000
+ idx_ue_start
+ 1
+ (modimpl.module.module_type or 0) * 1000
+ (modimpl.module.numero or 0),
) )
row[f"_{col_id}_xls"] = val_fmt row[f"_{col_id}_xls"] = val_fmt
if modimpl.module.module_type == scu.ModuleType.MALUS: if modimpl.module.module_type == scu.ModuleType.MALUS:

View File

@ -157,6 +157,11 @@ class FormSemestre(db.Model):
def __repr__(self): def __repr__(self):
return f"<{self.__class__.__name__} {self.id} {self.titre_annee()}>" return f"<{self.__class__.__name__} {self.id} {self.titre_annee()}>"
def sort_key(self) -> tuple:
"""clé pour tris par ordre alphabétique
(pour avoir le plus récent d'abord, sort avec reverse=True)"""
return (self.date_debut, self.semestre_id)
def to_dict(self, convert_objects=False) -> dict: def to_dict(self, convert_objects=False) -> dict:
"""dict (compatible ScoDoc7). """dict (compatible ScoDoc7).
If convert_objects, convert all attributes to native types If convert_objects, convert all attributes to native types
@ -325,7 +330,7 @@ class FormSemestre(db.Model):
if self.formation.is_apc(): if self.formation.is_apc():
modimpls.sort( modimpls.sort(
key=lambda m: ( key=lambda m: (
m.module.module_type or 0, m.module.module_type or 0, # ressources (2) avant SAEs (3)
m.module.numero or 0, m.module.numero or 0,
m.module.code or 0, m.module.code or 0,
) )

View File

@ -39,6 +39,7 @@ from app.but import apc_edit_ue
from app.models import APO_CODE_STR_LEN, SHORT_STR_LEN from app.models import APO_CODE_STR_LEN, SHORT_STR_LEN
from app.models import ( from app.models import (
Formation, Formation,
FormSemestre,
FormSemestreUEComputationExpr, FormSemestreUEComputationExpr,
FormSemestreUECoef, FormSemestreUECoef,
Matiere, Matiere,
@ -936,19 +937,24 @@ du programme" (menu "Semestre") si vous avez un semestre en cours);
<h3> <a name="sems">Semestres ou sessions de cette formation</a></h3> <h3> <a name="sems">Semestres ou sessions de cette formation</a></h3>
<p><ul>""" <p><ul>"""
) )
for sem in sco_formsemestre.do_formsemestre_list( for formsemestre in sorted(
args={"formation_id": formation_id} FormSemestre.query.filter_by(formation_id=formation_id).all(),
key=lambda s: s.sort_key(),
reverse=True,
): ):
H.append( H.append(
'<li><a class="stdlink" href="formsemestre_status?formsemestre_id=%(formsemestre_id)s">%(titremois)s</a>' f"""<li><a class="stdlink" href="{
% sem url_for("notes.formsemestre_status", scodoc_dept=g.scodoc_dept,
formsemestre_id=formsemestre.id
)}">{formsemestre.titre_mois()}</a>"""
) )
if not sem["etat"]: if not formsemestre.etat:
H.append(" [verrouillé]") H.append(" [verrouillé]")
else: else:
H.append( H.append(
' <a class="stdlink" href="formsemestre_editwithmodules?formation_id=%(formation_id)s&formsemestre_id=%(formsemestre_id)s">Modifier</a>' f""" &nbsp;<a class="stdlink" href="{url_for("notes.formsemestre_editwithmodules",
% sem scodoc_dept=g.scodoc_dept, formsemestre_id=formsemestre.id
)}">Modifier</a>"""
) )
H.append("</li>") H.append("</li>")
H.append("</ul>") H.append("</ul>")

View File

@ -179,7 +179,6 @@ def formsemestre_status_menubar(formsemestre: FormSemestre) -> str:
"title": "Modifier le semestre", "title": "Modifier le semestre",
"endpoint": "notes.formsemestre_editwithmodules", "endpoint": "notes.formsemestre_editwithmodules",
"args": { "args": {
"formation_id": formation.id,
"formsemestre_id": formsemestre_id, "formsemestre_id": formsemestre_id,
}, },
"enabled": can_modify_sem, "enabled": can_modify_sem,

View File

@ -1262,6 +1262,8 @@ def gen_cell(key: str, row: dict, elt="td", with_col_class=False):
if with_col_class: if with_col_class:
klass = key + " " + klass klass = key + " " + klass
attrs = f'class="{klass}"' if klass else "" attrs = f'class="{klass}"' if klass else ""
if elt == "th":
attrs += ' scope="row"'
data = row.get(f"_{key}_data") # dict data = row.get(f"_{key}_data") # dict
if data: if data:
for k in data: for k in data:

View File

@ -272,7 +272,8 @@ def formsemestre_bulletinetud(
code_ine=None, code_ine=None,
): ):
format = format or "html" format = format or "html"
if not isinstance(etudid, int):
raise ScoInvalidIdType("formsemestre_bulletinetud: etudid must be an integer !")
if formsemestre_id is not None and not isinstance(formsemestre_id, int): if formsemestre_id is not None and not isinstance(formsemestre_id, int):
raise ScoInvalidIdType( raise ScoInvalidIdType(
"formsemestre_bulletinetud: formsemestre_id must be an integer !" "formsemestre_bulletinetud: formsemestre_id must be an integer !"