Clé tri étudiants: laisse espaces internes

This commit is contained in:
Emmanuel Viennet 2022-07-03 11:30:07 +02:00
parent 962015563a
commit c1f7bcdb92
3 changed files with 9 additions and 7 deletions

View File

@ -136,9 +136,9 @@ class Identite(db.Model):
"clé pour tris par ordre alphabétique" "clé pour tris par ordre alphabétique"
return ( return (
scu.sanitize_string( scu.sanitize_string(
scu.suppress_accents(self.nom_usuel or self.nom or "").lower() self.nom_usuel or self.nom or "", remove_spaces=False
), ).lower(),
scu.sanitize_string(scu.suppress_accents(self.prenom or "").lower()), scu.sanitize_string(self.prenom or "", remove_spaces=False).lower(),
) )
def get_first_email(self, field="email") -> str: def get_first_email(self, field="email") -> str:

View File

@ -451,7 +451,7 @@ def ue_edit(ue_id=None, create=False, formation_id=None, default_semestre_idx=No
<ul>""" <ul>"""
for m in ue.modules: for m in ue.modules:
modules_div += f"""<li><a class="stdlink" href="{url_for( modules_div += f"""<li><a class="stdlink" href="{url_for(
"notes.module_edit",scodoc_dept=g.scodoc_dept, module_id=m.id)}">{m.code} {m.titre}</a></li>""" "notes.module_edit",scodoc_dept=g.scodoc_dept, module_id=m.id)}">{m.code} {m.titre or "sans titre"}</a></li>"""
modules_div += """</ul></div>""" modules_div += """</ul></div>"""
else: else:
modules_div = "" modules_div = ""

View File

@ -588,7 +588,7 @@ def purge_chars(s, allowed_chars=""):
return s.translate(PurgeChars(allowed_chars=allowed_chars)) return s.translate(PurgeChars(allowed_chars=allowed_chars))
def sanitize_string(s): def sanitize_string(s, remove_spaces=True):
"""s is an ordinary string, encoding given by SCO_ENCODING" """s is an ordinary string, encoding given by SCO_ENCODING"
suppress accents and chars interpreted in XML suppress accents and chars interpreted in XML
Irreversible (not a quote) Irreversible (not a quote)
@ -596,8 +596,10 @@ def sanitize_string(s):
For ids and some filenames For ids and some filenames
""" """
# Table suppressing some chars: # Table suppressing some chars:
trans = str.maketrans("", "", "'`\"<>!&\\ ") to_del = "'`\"<>!&\\ " if remove_spaces else "'`\"<>!&"
return suppress_accents(s.translate(trans)).replace(" ", "_").replace("\t", "_") trans = str.maketrans("", "", to_del)
return suppress_accents(s.translate(trans)).replace("\t", "_")
_BAD_FILENAME_CHARS = str.maketrans("", "", ":/\\&[]*?'") _BAD_FILENAME_CHARS = str.maketrans("", "", ":/\\&[]*?'")