forked from ScoDoc/ScoDoc
code cleaning
This commit is contained in:
parent
9b23ba4c96
commit
e9234d958a
@ -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"],
|
}">{etud.nomprenom}</a>"""
|
||||||
)
|
for etud in sorted(etuds, key=attrgetter("sort_key"))
|
||||||
for etud in etuds
|
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -479,17 +479,18 @@ 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()
|
||||||
first = True
|
if admission:
|
||||||
for cid, title in fields.items():
|
first = True
|
||||||
cell = row.add_cell(
|
for cid, title in fields.items():
|
||||||
cid,
|
cell = row.add_cell(
|
||||||
title,
|
cid,
|
||||||
getattr(admission, cid) or "",
|
title,
|
||||||
"admission",
|
getattr(admission, cid) or "",
|
||||||
)
|
"admission",
|
||||||
if first:
|
)
|
||||||
cell.classes.append("admission_first")
|
if first:
|
||||||
first = False
|
cell.classes.append("admission_first")
|
||||||
|
first = False
|
||||||
|
|
||||||
def add_cursus(self):
|
def add_cursus(self):
|
||||||
"""Ajoute colonne avec code cursus, eg 'S1 S2 S1'
|
"""Ajoute colonne avec code cursus, eg 'S1 S2 S1'
|
||||||
|
Loading…
Reference in New Issue
Block a user