1
0
forked from ScoDoc/ScoDoc

Tri tables sans diacritiques. Closes #122

This commit is contained in:
Emmanuel Viennet 2022-04-03 23:26:13 +02:00
parent 795de44c0c
commit 83d538e2a2
3 changed files with 17 additions and 10 deletions

View File

@ -469,10 +469,12 @@ class ResultatsSemestre(ResultatsCache):
idx = add_cell( idx = add_cell(
row, "nom_disp", "Nom", etud.nom_disp(), "identite_detail", idx row, "nom_disp", "Nom", etud.nom_disp(), "identite_detail", idx
) )
row["_nom_disp_order"] = etud.sort_key
idx = add_cell(row, "prenom", "Prénom", etud.prenom, "identite_detail", idx) idx = add_cell(row, "prenom", "Prénom", etud.prenom, "identite_detail", idx)
idx = add_cell( idx = add_cell(
row, "nom_short", "Nom", etud.nom_short, "identite_court", idx row, "nom_short", "Nom", etud.nom_short, "identite_court", idx
) )
row["_nom_short_order"] = etud.sort_key
row["_nom_short_target"] = url_for( row["_nom_short_target"] = url_for(
"notes.formsemestre_bulletinetud", "notes.formsemestre_bulletinetud",
scodoc_dept=g.scodoc_dept, scodoc_dept=g.scodoc_dept,

View File

@ -131,7 +131,10 @@ class Identite(db.Model):
@cached_property @cached_property
def sort_key(self) -> tuple: def sort_key(self) -> tuple:
"clé pour tris par ordre alphabétique" "clé pour tris par ordre alphabétique"
return (self.nom_usuel or self.nom).lower(), self.prenom.lower() return (
scu.suppress_accents(self.nom_usuel or self.nom or "").lower(),
scu.suppress_accents(self.prenom or "").lower(),
)
def get_first_email(self, field="email") -> str: def get_first_email(self, field="email") -> str:
"Le mail associé à la première adrese de l'étudiant, ou None" "Le mail associé à la première adrese de l'étudiant, ou None"

View File

@ -41,6 +41,7 @@ from app.comp.moy_mod import ModuleImplResults
from app.comp.res_compat import NotesTableCompat from app.comp.res_compat import NotesTableCompat
from app.comp.res_but import ResultatsSemestreBUT from app.comp.res_but import ResultatsSemestreBUT
from app.models import FormSemestre from app.models import FormSemestre
from app.models.etudiants import Identite
from app.models.evaluations import Evaluation from app.models.evaluations import Evaluation
from app.models.moduleimpls import ModuleImpl from app.models.moduleimpls import ModuleImpl
import app.scodoc.sco_utils as scu import app.scodoc.sco_utils as scu
@ -53,7 +54,6 @@ from app.scodoc import sco_formsemestre
from app.scodoc import sco_groups from app.scodoc import sco_groups
from app.scodoc import sco_moduleimpl from app.scodoc import sco_moduleimpl
from app.scodoc import sco_preferences from app.scodoc import sco_preferences
from app.scodoc import sco_etud
from app.scodoc import sco_users from app.scodoc import sco_users
import sco_version import sco_version
from app.scodoc.gen_tables import GenTable from app.scodoc.gen_tables import GenTable
@ -320,7 +320,9 @@ def _make_table_notes(
for etudid, etat in etudid_etats: for etudid, etat in etudid_etats:
css_row_class = None css_row_class = None
# infos identite etudiant # infos identite etudiant
etud = sco_etud.get_etud_info(etudid=etudid, filled=True)[0] etud = Identite.query.get(etudid)
if etud is None:
continue
if etat == "I": # si inscrit, indique groupe if etat == "I": # si inscrit, indique groupe
groups = sco_groups.get_etud_groups(etudid, modimpl_o["formsemestre_id"]) groups = sco_groups.get_etud_groups(etudid, modimpl_o["formsemestre_id"])
@ -332,7 +334,7 @@ def _make_table_notes(
else: else:
grc = etat grc = etat
code = etud.get(anonymous_lst_key) code = getattr(etud, anonymous_lst_key)
if not code: # laisser le code vide n'aurait aucun sens, prenons l'etudid if not code: # laisser le code vide n'aurait aucun sens, prenons l'etudid
code = etudid code = etudid
@ -341,20 +343,20 @@ def _make_table_notes(
"code": str(code), # INE, NIP ou etudid "code": str(code), # INE, NIP ou etudid
"_code_td_attrs": 'style="padding-left: 1em; padding-right: 2em;"', "_code_td_attrs": 'style="padding-left: 1em; padding-right: 2em;"',
"etudid": etudid, "etudid": etudid,
"nom": etud["nom"].upper(), "nom": etud.nom.upper(),
"_nomprenom_target": url_for( "_nomprenom_target": url_for(
"notes.formsemestre_bulletinetud", "notes.formsemestre_bulletinetud",
scodoc_dept=g.scodoc_dept, scodoc_dept=g.scodoc_dept,
formsemestre_id=modimpl_o["formsemestre_id"], formsemestre_id=modimpl_o["formsemestre_id"],
etudid=etudid, etudid=etudid,
), ),
"_nomprenom_td_attrs": f"""id="{etudid}" class="etudinfo" data-sort="{etud.get('nom', '').upper()}" """, "_nomprenom_td_attrs": f"""id="{etudid}" class="etudinfo" data-sort="{etud.sort_key}" """,
"prenom": etud["prenom"].lower().capitalize(), "prenom": etud.prenom.lower().capitalize(),
"nomprenom": etud["nomprenom"], "nomprenom": etud.nomprenom,
"group": grc, "group": grc,
"_group_td_attrs": 'class="group"', "_group_td_attrs": 'class="group"',
"email": etud["email"], "email": etud.get_first_email(),
"emailperso": etud["emailperso"], "emailperso": etud.get_first_email("emailperso"),
"_css_row_class": css_row_class or "", "_css_row_class": css_row_class or "",
} }
) )