diff --git a/app/scodoc/sco_moduleimpl_inscriptions.py b/app/scodoc/sco_moduleimpl_inscriptions.py
index ec5ff86e78..03217dc7ae 100644
--- a/app/scodoc/sco_moduleimpl_inscriptions.py
+++ b/app/scodoc/sco_moduleimpl_inscriptions.py
@@ -28,7 +28,7 @@
"""Opérations d'inscriptions aux modules (interface pour gérer options ou parcours)
"""
import collections
-from operator import itemgetter
+from operator import attrgetter
import flask
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))
#
d = []
- for (partition_name, grp) in gr:
+ for partition_name, grp in gr:
if grp:
d.append("groupes de %s: %s" % (partition_name, ", ".join(grp)))
r = []
@@ -683,25 +683,25 @@ def descr_inscrs_module(moduleimpl_id, set_all, partitions):
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
# au delà, on indique juste le nombre, sans les noms.
- if len(ins) > max_list_size:
- return "%d étudiants" % len(ins)
+ if len(etudids) > max_list_size:
+ return f"{len(etudids)} étudiants"
etuds = []
- for etudid in ins:
- etuds.append(sco_etud.get_etud_info(etudid=etudid, filled=True)[0])
- etuds.sort(key=itemgetter("nom"))
+ for etudid in etudids:
+ etud = Identite.query.get(etudid)
+ if etud:
+ etuds.append(etud)
+
return ", ".join(
[
- '%s'
- % (
+ f"""{etud.nomprenom}"""
+ for etud in sorted(etuds, key=attrgetter("sort_key"))
]
)
diff --git a/app/tables/recap.py b/app/tables/recap.py
index 73764ed224..5fca29127e 100644
--- a/app/tables/recap.py
+++ b/app/tables/recap.py
@@ -479,17 +479,18 @@ class TableRecap(tb.Table):
for row in self.rows:
etud = row.etud
admission = etud.admission.first()
- first = True
- for cid, title in fields.items():
- cell = row.add_cell(
- cid,
- title,
- getattr(admission, cid) or "",
- "admission",
- )
- if first:
- cell.classes.append("admission_first")
- first = False
+ if admission:
+ first = True
+ for cid, title in fields.items():
+ cell = row.add_cell(
+ cid,
+ title,
+ getattr(admission, cid) or "",
+ "admission",
+ )
+ if first:
+ cell.classes.append("admission_first")
+ first = False
def add_cursus(self):
"""Ajoute colonne avec code cursus, eg 'S1 S2 S1'