Fix ordre colonnes res/sae dans tableau recap.

This commit is contained in:
Emmanuel Viennet 2023-01-14 14:01:54 -03:00
parent 393c205cb9
commit 109123bdf5
6 changed files with 34 additions and 16 deletions

View File

@ -494,7 +494,7 @@ class ResultatsSemestre(ResultatsCache):
classes: str = "",
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
if classes:
row[f"_{col_id}_class"] = classes + f" c{idx}"
@ -569,7 +569,8 @@ class ResultatsSemestre(ResultatsCache):
)
# --- Moyenne d'UE
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)
if ue_status is not None:
col_id = f"moy_ue_{ue.id}"
@ -590,7 +591,7 @@ class ResultatsSemestre(ResultatsCache):
ue.acronyme,
fmt_note(val),
"col_ue" + note_class,
idx,
idx_ue * 10000 + idx_ue_start,
)
titles_bot[
f"_{col_id}_target_attrs"
@ -611,7 +612,7 @@ class ResultatsSemestre(ResultatsCache):
f"Bonus {ue.acronyme}",
val_fmt_html if allow_html else val_fmt,
"col_ue_bonus",
idx,
idx_ue * 10000 + idx_ue_start + 1,
)
row[f"_bonus_ue_{ue.id}_xls"] = val_fmt
# Les moyennes des modules (ou ressources et SAÉs) dans cette UE
@ -656,7 +657,11 @@ class ResultatsSemestre(ResultatsCache):
val_fmt_html,
# class col_res mod_ue_123
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
if modimpl.module.module_type == scu.ModuleType.MALUS:

View File

@ -157,6 +157,11 @@ class FormSemestre(db.Model):
def __repr__(self):
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:
"""dict (compatible ScoDoc7).
If convert_objects, convert all attributes to native types
@ -325,7 +330,7 @@ class FormSemestre(db.Model):
if self.formation.is_apc():
modimpls.sort(
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.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 (
Formation,
FormSemestre,
FormSemestreUEComputationExpr,
FormSemestreUECoef,
Matiere,
@ -925,7 +926,7 @@ du programme" (menu "Semestre") si vous avez un semestre en cours);
<li><a class="stdlink" href="{
url_for('notes.module_table', scodoc_dept=g.scodoc_dept,
formation_id=formation_id)
}">Liste détaillée des modules de la formation</a> (debug)
}">Liste détaillée des modules de la formation</a> (debug)
</li>
</ul>
</p>"""
@ -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>
<p><ul>"""
)
for sem in sco_formsemestre.do_formsemestre_list(
args={"formation_id": formation_id}
for formsemestre in sorted(
FormSemestre.query.filter_by(formation_id=formation_id).all(),
key=lambda s: s.sort_key(),
reverse=True,
):
H.append(
'<li><a class="stdlink" href="formsemestre_status?formsemestre_id=%(formsemestre_id)s">%(titremois)s</a>'
% sem
f"""<li><a class="stdlink" href="{
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é]")
else:
H.append(
' <a class="stdlink" href="formsemestre_editwithmodules?formation_id=%(formation_id)s&formsemestre_id=%(formsemestre_id)s">Modifier</a>'
% sem
f""" &nbsp;<a class="stdlink" href="{url_for("notes.formsemestre_editwithmodules",
scodoc_dept=g.scodoc_dept, formsemestre_id=formsemestre.id
)}">Modifier</a>"""
)
H.append("</li>")
H.append("</ul>")

View File

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

View File

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

View File

@ -272,7 +272,8 @@ def formsemestre_bulletinetud(
code_ine=None,
):
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):
raise ScoInvalidIdType(
"formsemestre_bulletinetud: formsemestre_id must be an integer !"