forked from ScoDoc/ScoDoc
Clé tri étudiants: laisse espaces internes
This commit is contained in:
parent
962015563a
commit
c1f7bcdb92
@ -136,9 +136,9 @@ class Identite(db.Model):
|
||||
"clé pour tris par ordre alphabétique"
|
||||
return (
|
||||
scu.sanitize_string(
|
||||
scu.suppress_accents(self.nom_usuel or self.nom or "").lower()
|
||||
),
|
||||
scu.sanitize_string(scu.suppress_accents(self.prenom or "").lower()),
|
||||
self.nom_usuel or self.nom or "", remove_spaces=False
|
||||
).lower(),
|
||||
scu.sanitize_string(self.prenom or "", remove_spaces=False).lower(),
|
||||
)
|
||||
|
||||
def get_first_email(self, field="email") -> str:
|
||||
|
@ -451,7 +451,7 @@ def ue_edit(ue_id=None, create=False, formation_id=None, default_semestre_idx=No
|
||||
<ul>"""
|
||||
for m in ue.modules:
|
||||
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>"""
|
||||
else:
|
||||
modules_div = ""
|
||||
|
@ -588,7 +588,7 @@ def purge_chars(s, 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"
|
||||
suppress accents and chars interpreted in XML
|
||||
Irreversible (not a quote)
|
||||
@ -596,8 +596,10 @@ def sanitize_string(s):
|
||||
For ids and some filenames
|
||||
"""
|
||||
# Table suppressing some chars:
|
||||
trans = str.maketrans("", "", "'`\"<>!&\\ ")
|
||||
return suppress_accents(s.translate(trans)).replace(" ", "_").replace("\t", "_")
|
||||
to_del = "'`\"<>!&\\ " if remove_spaces else "'`\"<>!&"
|
||||
trans = str.maketrans("", "", to_del)
|
||||
|
||||
return suppress_accents(s.translate(trans)).replace("\t", "_")
|
||||
|
||||
|
||||
_BAD_FILENAME_CHARS = str.maketrans("", "", ":/\\&[]*?'")
|
||||
|
Loading…
Reference in New Issue
Block a user