code cleaning

This commit is contained in:
Emmanuel Viennet 2023-06-07 18:43:44 +02:00 committed by iziram
parent 9b23ba4c96
commit e9234d958a
2 changed files with 27 additions and 26 deletions

View File

@ -28,7 +28,7 @@
"""Opérations d'inscriptions aux modules (interface pour gérer options ou parcours) """Opérations d'inscriptions aux modules (interface pour gérer options ou parcours)
""" """
import collections import collections
from operator import itemgetter from operator import attrgetter
import flask import flask
from flask import url_for, g, request from flask import url_for, g, request
@ -671,7 +671,7 @@ def descr_inscrs_module(moduleimpl_id, set_all, partitions):
gr.append((partition["partition_name"], grp)) gr.append((partition["partition_name"], grp))
# #
d = [] d = []
for (partition_name, grp) in gr: for partition_name, grp in gr:
if grp: if grp:
d.append("groupes de %s: %s" % (partition_name, ", ".join(grp))) d.append("groupes de %s: %s" % (partition_name, ", ".join(grp)))
r = [] r = []
@ -683,25 +683,25 @@ def descr_inscrs_module(moduleimpl_id, set_all, partitions):
return False, len(ins), " et ".join(r) return False, len(ins), " et ".join(r)
def _fmt_etud_set(ins, max_list_size=7): def _fmt_etud_set(etudids, max_list_size=7) -> str:
# max_list_size est le nombre max de noms d'etudiants listés # max_list_size est le nombre max de noms d'etudiants listés
# au delà, on indique juste le nombre, sans les noms. # au delà, on indique juste le nombre, sans les noms.
if len(ins) > max_list_size: if len(etudids) > max_list_size:
return "%d étudiants" % len(ins) return f"{len(etudids)} étudiants"
etuds = [] etuds = []
for etudid in ins: for etudid in etudids:
etuds.append(sco_etud.get_etud_info(etudid=etudid, filled=True)[0]) etud = Identite.query.get(etudid)
etuds.sort(key=itemgetter("nom")) if etud:
etuds.append(etud)
return ", ".join( return ", ".join(
[ [
'<a class="discretelink" href="%s">%s</a>' f"""<a class="discretelink" href="{
% (
url_for( url_for(
"scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etud["etudid"] "scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etud.id
),
etud["nomprenom"],
) )
for etud in etuds }">{etud.nomprenom}</a>"""
for etud in sorted(etuds, key=attrgetter("sort_key"))
] ]
) )

View File

@ -479,6 +479,7 @@ class TableRecap(tb.Table):
for row in self.rows: for row in self.rows:
etud = row.etud etud = row.etud
admission = etud.admission.first() admission = etud.admission.first()
if admission:
first = True first = True
for cid, title in fields.items(): for cid, title in fields.items():
cell = row.add_cell( cell = row.add_cell(