Tableaux génériques: possibilité de déclarer un colonne seulement pour excel. Assiduité: ajout etudid et NIP a visu_assi_group: closes #873.

This commit is contained in:
Emmanuel Viennet 2024-04-10 15:09:32 +02:00
parent c2443c361f
commit b861aba6a3
3 changed files with 40 additions and 8 deletions

View File

@ -265,6 +265,8 @@ class Table(Element):
title: str = None, title: str = None,
classes: list[str] = None, classes: list[str] = None,
raw_title: str = None, raw_title: str = None,
no_excel: bool = False,
only_excel: bool = False,
) -> 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.
@ -282,6 +284,8 @@ class Table(Element):
classes=classes, classes=classes,
group=self.column_group.get(col_id), group=self.column_group.get(col_id),
raw_content=raw_title or title, raw_content=raw_title or title,
no_excel=no_excel,
only_excel=only_excel,
) )
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(
@ -370,6 +374,7 @@ class Row(Element):
target_attrs: dict = None, target_attrs: dict = None,
target: str = None, target: str = None,
column_classes: set[str] = None, column_classes: set[str] = None,
only_excel: bool = False,
no_excel: bool = False, no_excel: bool = False,
) -> "Cell": ) -> "Cell":
"""Create cell and add it to the row. """Create cell and add it to the row.
@ -397,6 +402,7 @@ class Row(Element):
column_group=group, column_group=group,
title=title, title=title,
raw_title=raw_title, raw_title=raw_title,
only_excel=only_excel,
no_excel=no_excel, no_excel=no_excel,
) )
@ -406,6 +412,7 @@ class Row(Element):
cell: "Cell", cell: "Cell",
column_group: str | None = None, column_group: str | None = None,
title: str | None = None, title: str | None = None,
only_excel: bool = False,
no_excel: bool = False, no_excel: bool = False,
raw_title: str | None = None, raw_title: str | None = None,
) -> "Cell": ) -> "Cell":
@ -414,10 +421,10 @@ class Row(Element):
""" """
cell.data["group"] = column_group or "" cell.data["group"] = column_group or ""
self.cells[col_id] = cell self.cells[col_id] = cell
if col_id not in self.table.column_ids: if not only_excel and col_id not in self.table.column_ids:
self.table.column_ids.append(col_id) self.table.column_ids.append(col_id)
if not no_excel: if not no_excel and col_id not in self.table.raw_column_ids:
self.table.raw_column_ids.append(col_id) self.table.raw_column_ids.append(col_id)
self.table.insert_group(column_group) self.table.insert_group(column_group)
if column_group is not None: if column_group is not None:
@ -425,7 +432,12 @@ class Row(Element):
if title is not None: if title is not None:
self.table.add_title( self.table.add_title(
col_id, title, classes=cell.classes, raw_title=raw_title col_id,
title,
classes=cell.classes,
raw_title=raw_title,
no_excel=no_excel,
only_excel=only_excel,
) )
return cell return cell

View File

@ -6,14 +6,15 @@
"""Liste simple d'étudiants """Liste simple d'étudiants
""" """
import datetime
from flask import g, url_for from flask import g, url_for
from app import log from app import log
from app.models import FormSemestre, Identite, Justificatif from app.models import FormSemestre, Identite, Justificatif
from app.tables import table_builder as tb from app.tables import table_builder as tb
import app.scodoc.sco_assiduites as scass
from app.scodoc import sco_preferences from app.scodoc import sco_preferences
from app.scodoc import sco_utils as scu from app.scodoc import sco_utils as scu
import app.scodoc.sco_assiduites as scass
from app.scodoc.sco_exceptions import ScoValueError
class TableAssi(tb.Table): class TableAssi(tb.Table):
@ -39,7 +40,13 @@ class TableAssi(tb.Table):
): ):
self.rows: list["RowAssi"] = [] # juste pour que VSCode nous aide sur .rows self.rows: list["RowAssi"] = [] # juste pour que VSCode nous aide sur .rows
classes = ["gt_table"] classes = ["gt_table"]
self.dates = [str(dates[0]) + "T00:00", str(dates[1]) + "T23:59"] try:
self.dates = [
datetime.datetime.fromisoformat(str(dates[0]) + "T00:00"),
datetime.datetime.fromisoformat(str(dates[1]) + "T00:00"),
]
except ValueError as exc:
raise ScoValueError("invalid dates") from exc
self.formsemestre = formsemestre self.formsemestre = formsemestre
self.formsemestre_modimpls = formsemestre_modimpls self.formsemestre_modimpls = formsemestre_modimpls
if convert_values: if convert_values:
@ -97,6 +104,20 @@ class RowAssi(tb.Row):
bilan_etud = url_for( bilan_etud = url_for(
"assiduites.bilan_etud", scodoc_dept=g.scodoc_dept, etudid=etud.id "assiduites.bilan_etud", scodoc_dept=g.scodoc_dept, etudid=etud.id
) )
self.add_cell(
"etudid",
"etudid",
etud.etudid,
"etudinfo",
only_excel=True,
)
self.add_cell(
"code_nip",
"code_nip",
etud.code_nip,
"etudinfo",
only_excel=True,
)
self.add_cell( self.add_cell(
"nom_disp", "nom_disp",
"Nom", "Nom",

View File

@ -1440,7 +1440,6 @@ def visu_assi_group():
formsemestre_modimpls=formsemestre_modimpls, formsemestre_modimpls=formsemestre_modimpls,
convert_values=(fmt == "html"), convert_values=(fmt == "html"),
) )
# Export en XLS # Export en XLS
if fmt.startswith("xls"): if fmt.startswith("xls"):
return scu.send_file( return scu.send_file(