Fix export excel table jury. Closes #868

This commit is contained in:
Emmanuel Viennet 2024-03-22 17:39:48 +01:00
parent 635269ff36
commit 715e4f94ee
6 changed files with 40 additions and 26 deletions

View File

@ -542,8 +542,6 @@ class Identite(models.ScoDocModel):
def inscriptions(self) -> list["FormSemestreInscription"]: def inscriptions(self) -> list["FormSemestreInscription"]:
"Liste des inscriptions à des formsemestres, triée, la plus récente en tête" "Liste des inscriptions à des formsemestres, triée, la plus récente en tête"
from app.models.formsemestre import FormSemestre, FormSemestreInscription
return ( return (
FormSemestreInscription.query.join(FormSemestreInscription.formsemestre) FormSemestreInscription.query.join(FormSemestreInscription.formsemestre)
.filter( .filter(
@ -569,8 +567,6 @@ class Identite(models.ScoDocModel):
(il est rare qu'il y en ai plus d'une, mais c'est possible). (il est rare qu'il y en ai plus d'une, mais c'est possible).
Triées par date de début de semestre décroissante (le plus récent en premier). Triées par date de début de semestre décroissante (le plus récent en premier).
""" """
from app.models.formsemestre import FormSemestre, FormSemestreInscription
return ( return (
FormSemestreInscription.query.join(FormSemestreInscription.formsemestre) FormSemestreInscription.query.join(FormSemestreInscription.formsemestre)
.filter( .filter(
@ -1099,6 +1095,5 @@ class EtudAnnotation(db.Model):
return e return e
from app.models.formsemestre import FormSemestre from app.models.formsemestre import FormSemestre, FormSemestreInscription
from app.models.modules import Module
from app.models.moduleimpls import ModuleImpl, ModuleImplInscription from app.models.moduleimpls import ModuleImpl, ModuleImplInscription

View File

@ -57,14 +57,12 @@ from app.scodoc import html_sco_header
from app.scodoc import sco_assiduites from app.scodoc import sco_assiduites
from app.scodoc import codes_cursus from app.scodoc import codes_cursus
from app.scodoc import sco_cache from app.scodoc import sco_cache
from app.scodoc import sco_edit_ue
from app.scodoc import sco_etud from app.scodoc import sco_etud
from app.scodoc import sco_formsemestre from app.scodoc import sco_formsemestre
from app.scodoc import sco_formsemestre_inscriptions from app.scodoc import sco_formsemestre_inscriptions
from app.scodoc import sco_cursus from app.scodoc import sco_cursus
from app.scodoc import sco_cursus_dut from app.scodoc import sco_cursus_dut
from app.scodoc.sco_cursus_dut import etud_est_inscrit_ue from app.scodoc.sco_cursus_dut import etud_est_inscrit_ue
from app.scodoc import sco_photos
from app.scodoc import sco_preferences from app.scodoc import sco_preferences
from app.scodoc import sco_pv_dict from app.scodoc import sco_pv_dict
from app.scodoc.sco_permissions import Permission from app.scodoc.sco_permissions import Permission

View File

@ -110,7 +110,7 @@ def formsemestre_recapcomplet(
force_publishing=force_publishing, force_publishing=force_publishing,
) )
table_html, table, freq_codes_annuels = _formsemestre_recapcomplet_to_html( table_html, _, freq_codes_annuels = _formsemestre_recapcomplet_to_html(
formsemestre, formsemestre,
filename=filename, filename=filename,
mode_jury=mode_jury, mode_jury=mode_jury,

View File

@ -8,21 +8,16 @@
""" """
import collections import collections
import time
import numpy as np import numpy as np
from flask import g, url_for from flask import g, url_for
from app.but import cursus_but from app.but import cursus_but
from app.but import jury_but from app.but import jury_but
from app.but.jury_but import ( from app.but.jury_but import DecisionsProposeesRCUE
DecisionsProposeesAnnee,
DecisionsProposeesRCUE,
DecisionsProposeesUE,
)
from app.comp.res_compat import NotesTableCompat from app.comp.res_compat import NotesTableCompat
from app.models import ApcNiveau, UniteEns from app.models import ApcNiveau, UniteEns
from app.models.etudiants import Identite from app.models.etudiants import Identite
from app.models.formsemestre import FormSemestre
from app.scodoc.codes_cursus import ( from app.scodoc.codes_cursus import (
BUT_BARRE_RCUE, BUT_BARRE_RCUE,
BUT_RCUE_SUFFISANT, BUT_RCUE_SUFFISANT,
@ -112,9 +107,11 @@ class TableJury(TableRecap):
row.add_cell( row.add_cell(
"autorisations_inscription", "autorisations_inscription",
"Passage", "Passage",
", ".join("S" + str(i) for i in sorted(autorisations[etud.id])) (
if etud.id in autorisations ", ".join("S" + str(i) for i in sorted(autorisations[etud.id]))
else "", if etud.id in autorisations
else ""
),
group="jury_code_sem", group="jury_code_sem",
classes=["recorded_code"], classes=["recorded_code"],
) )
@ -136,6 +133,7 @@ class TableJury(TableRecap):
if not self.read_only else "voir"} décisions""", if not self.read_only else "voir"} décisions""",
group="col_jury_link", group="col_jury_link",
classes=["fontred"] if a_saisir else [], classes=["fontred"] if a_saisir else [],
no_excel=True,
target=url_for( target=url_for(
"notes.formsemestre_validation_etud_form", "notes.formsemestre_validation_etud_form",
scodoc_dept=g.scodoc_dept, scodoc_dept=g.scodoc_dept,
@ -278,6 +276,7 @@ class RowJury(RowRecap):
f"<div>{rcue.ue_1.acronyme}</div><div>{rcue.ue_2.acronyme}</div>", f"<div>{rcue.ue_1.acronyme}</div><div>{rcue.ue_2.acronyme}</div>",
self.table.fmt_note(val), self.table.fmt_note(val),
raw_content=val, raw_content=val,
raw_title=f"{rcue.ue_1.acronyme}-{rcue.ue_2.acronyme}",
group="rcue", group="rcue",
classes=[note_class], classes=[note_class],
column_classes={"col_rcue"}, column_classes={"col_rcue"},
@ -293,6 +292,7 @@ class RowJury(RowRecap):
"empty_code" if not dec_rcue.code_valide else "", "empty_code" if not dec_rcue.code_valide else "",
], ],
column_classes={"col_rcue"}, column_classes={"col_rcue"},
raw_title=f"{rcue.ue_1.acronyme}-{rcue.ue_2.acronyme}",
) )
# # --- Les ECTS validés # # --- Les ECTS validés

View File

@ -613,6 +613,7 @@ class RowRecap(tb.Row):
"etudid": etud.id, "etudid": etud.id,
"nomprenom": etud.nomprenom, "nomprenom": etud.nomprenom,
}, },
no_excel=True,
target=url_bulletin, target=url_bulletin,
target_attrs={"class": "etudinfo", "id": str(etud.id)}, target_attrs={"class": "etudinfo", "id": str(etud.id)},
) )
@ -623,7 +624,11 @@ class RowRecap(tb.Row):
_, nbabsjust, nbabs = self.table.res.formsemestre.get_abs_count(self.etud.id) _, nbabsjust, nbabs = self.table.res.formsemestre.get_abs_count(self.etud.id)
self.add_cell("nbabs", "Abs", f"{nbabs:1.0f}", "abs", raw_content=nbabs) self.add_cell("nbabs", "Abs", f"{nbabs:1.0f}", "abs", raw_content=nbabs)
self.add_cell( self.add_cell(
"nbabsjust", "Just.", f"{nbabsjust:1.0f}", "abs", raw_content=nbabsjust "nbabsjust",
"Just.",
f"{nbabsjust:1.0f}",
"abs",
raw_content=nbabsjust,
) )
def add_moyennes_cols( def add_moyennes_cols(

View File

@ -260,12 +260,18 @@ class Table(Element):
self.titles.update(titles) self.titles.update(titles)
def add_title( def add_title(
self, col_id, title: str = None, classes: list[str] = None self,
col_id,
title: str = None,
classes: list[str] = None,
raw_title: str = None,
) -> tuple["Cell", "Cell"]: ) -> tuple["Cell", "Cell"]:
"""Record this title, """Record this title,
and create cells for footer and header if they don't already exist. and create cells for footer and header if they don't already exist.
If specified, raw_title will be used in excel exports.
""" """
title = title or "" title = title or ""
if col_id not in self.titles: if col_id not in self.titles:
self.titles[col_id] = title self.titles[col_id] = title
if self.head_title_row: if self.head_title_row:
@ -275,6 +281,7 @@ class Table(Element):
title, title,
classes=classes, classes=classes,
group=self.column_group.get(col_id), group=self.column_group.get(col_id),
raw_content=raw_title or title,
) )
if self.foot_title_row: if self.foot_title_row:
self.foot_title_row.cells[col_id] = self.foot_title_row.add_cell( self.foot_title_row.cells[col_id] = self.foot_title_row.add_cell(
@ -359,6 +366,7 @@ class Row(Element):
data: dict[str, str] = None, data: dict[str, str] = None,
elt: str = None, elt: str = None,
raw_content=None, raw_content=None,
raw_title: str | None = None,
target_attrs: dict = None, target_attrs: dict = None,
target: str = None, target: str = None,
column_classes: set[str] = None, column_classes: set[str] = None,
@ -384,16 +392,22 @@ class Row(Element):
target_attrs=target_attrs, target_attrs=target_attrs,
) )
return self.add_cell_instance( return self.add_cell_instance(
col_id, cell, column_group=group, title=title, no_excel=no_excel col_id,
cell,
column_group=group,
title=title,
raw_title=raw_title,
no_excel=no_excel,
) )
def add_cell_instance( def add_cell_instance(
self, self,
col_id: str, col_id: str,
cell: "Cell", cell: "Cell",
column_group: str = None, column_group: str | None = None,
title: str = None, title: str | None = None,
no_excel: bool = False, no_excel: bool = False,
raw_title: str | None = None,
) -> "Cell": ) -> "Cell":
"""Add a cell to the row. """Add a cell to the row.
Si title est None, il doit avoir été ajouté avec table.add_title(). Si title est None, il doit avoir été ajouté avec table.add_title().
@ -410,7 +424,9 @@ class Row(Element):
self.table.column_group[col_id] = column_group self.table.column_group[col_id] = column_group
if title is not None: if title is not None:
self.table.add_title(col_id, title, classes=cell.classes) self.table.add_title(
col_id, title, classes=cell.classes, raw_title=raw_title
)
return cell return cell
@ -487,7 +503,7 @@ class Cell(Element):
self.attrs["scope"] = "row" self.attrs["scope"] = "row"
self.data = data.copy() if data else {} self.data = data.copy() if data else {}
self.raw_content = raw_content or content self.raw_content = content if raw_content is None else raw_content
self.target = target self.target = target
self.target_attrs = target_attrs or {} self.target_attrs = target_attrs or {}