Enrichissement du tableau des formations (coche 'détails')

This commit is contained in:
Emmanuel Viennet 2024-04-05 00:23:29 +02:00
parent a0e2af481f
commit bd9bf87112
4 changed files with 42 additions and 14 deletions

View File

@ -148,7 +148,7 @@ def _convert_formsemestres_to_dicts(
),
"formsemestre_id": formsemestre.id,
"groupicon": groupicon if nb_inscrits > 0 else emptygroupicon,
"lockimg": lockicon,
"lockimg": "" if formsemestre.etat else lockicon,
"modalite": formsemestre.modalite,
"mois_debut": formsemestre.mois_debut(),
"mois_fin": formsemestre.mois_fin(),

View File

@ -489,9 +489,10 @@ def formation_import_xml(doc: str, import_tags=True, use_local_refcomp=False):
return formation.id, modules_old2new, ues_old2new
def formation_list_table() -> GenTable:
def formation_list_table(detail: bool) -> GenTable:
"""List formation, grouped by titre and sorted by versions
and listing associated semestres
and listing associated semestres.
If detail, add column with more details.
returns a table
"""
formations: list[Formation] = Formation.query.filter_by(dept_id=g.scodoc_dept_id)
@ -534,6 +535,15 @@ def formation_list_table() -> GenTable:
if formation.referentiel_competence
else ""
),
"_referentiel_target": (
url_for(
"notes.refcomp_show",
scodoc_dept=g.scodoc_dept,
refcomp_id=formation.referentiel_competence.id,
)
if formation.referentiel_competence
else ""
),
}
# Ajoute les semestres associés à chaque formation:
row["formsemestres"] = formation.formsemestres.order_by(
@ -561,10 +571,15 @@ def formation_list_table() -> GenTable:
else []
)
)
# Répartition des UEs dans les semestres
# utilise pour voir si la formation couvre tous les semestres
row["semestres_ues"] = ", ".join(
"S" + str(x if (x is not None and x > 0) else "-")
for x in sorted({ue.semestre_idx for ue in formation.ues})
)
# Date surtout utilisées pour le tri:
if row["formsemestres"]:
row["date_fin_dernier_sem"] = (
row["formsemestres"][-1].date_fin.isoformat(),
)
row["date_fin_dernier_sem"] = row["formsemestres"][-1].date_fin.isoformat()
row["annee_dernier_sem"] = row["formsemestres"][-1].date_fin.year
else:
row["date_fin_dernier_sem"] = ""
@ -617,6 +632,8 @@ def formation_list_table() -> GenTable:
"commentaire",
"sems_list_txt",
)
if detail:
columns_ids += ("annee_dernier_sem", "semestres_ues")
titles = {
"buttons": "",
"commentaire": "Commentaire",
@ -627,6 +644,9 @@ def formation_list_table() -> GenTable:
"formation_code": "Code",
"sems_list_txt": "Semestres",
"referentiel": "Réf.",
"date_fin_dernier_sem": "Fin dernier sem.",
"annee_dernier_sem": "Année dernier sem.",
"semestres_ues": "Semestres avec UEs",
}
return GenTable(
columns_ids=columns_ids,
@ -639,7 +659,7 @@ def formation_list_table() -> GenTable:
html_class="formation_list_table table_leftalign",
html_with_td_classes=True,
html_sortable=True,
base_url=f"{request.base_url}",
base_url=f"{request.base_url}" + ("?detail=on" if detail else ""),
page_title=title,
pdf_title=title,
preferences=sco_preferences.SemPreferences(),

View File

@ -2411,10 +2411,10 @@ li.notes_formation_list {
padding-top: 10px;
}
table.formation_list_table {
width: 100%;
table.dataTable.formation_list_table.gt_table {
border-collapse: collapse;
background-color: rgb(0%, 90%, 90%);
margin-right: 12px;
margin-left: 12px;
}
table#formation_list_table tr.gt_hl {
@ -2455,8 +2455,8 @@ table.formation_list_table td.buttons span.but_placeholder {
text-align: center;
}
.formation_list_table td.titre {
width: 45%;
.formation_list_table td.sems_list_txt {
width: 15%;
}
.formation_list_table td.commentaire {

View File

@ -691,15 +691,23 @@ def module_clone():
def index_html():
"Page accueil formations"
fmt = request.args.get("fmt", "html")
detail = scu.to_bool(request.args.get("detail", False))
editable = current_user.has_permission(Permission.EditFormation)
table = sco_formations.formation_list_table()
table = sco_formations.formation_list_table(detail=detail)
if fmt != "html":
return table.make_page(fmt=fmt, filename=f"Formations-{g.scodoc_dept}")
H = [
html_sco_header.sco_header(page_title="Formations (programmes)"),
"""<h2>Formations (programmes pédagogiques)</h2>
f"""<h2>Formations (programmes pédagogiques)</h2>
<form>
<input type="checkbox" id="detailCheckbox" name="detail"
onchange="this.form.submit();"
{'checked' if detail else ''}>
<label for="detailCheckbox">Informations détaillées</label>
</form>
""",
table.html(),
]