diff --git a/app/tables/table_builder.py b/app/tables/table_builder.py index dc0ef6cd..d7e01358 100644 --- a/app/tables/table_builder.py +++ b/app/tables/table_builder.py @@ -265,6 +265,8 @@ class Table(Element): title: str = None, classes: list[str] = None, raw_title: str = None, + no_excel: bool = False, + only_excel: bool = False, ) -> tuple["Cell", "Cell"]: """Record this title, and create cells for footer and header if they don't already exist. @@ -282,6 +284,8 @@ class Table(Element): classes=classes, group=self.column_group.get(col_id), raw_content=raw_title or title, + no_excel=no_excel, + only_excel=only_excel, ) if self.foot_title_row: 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: str = None, column_classes: set[str] = None, + only_excel: bool = False, no_excel: bool = False, ) -> "Cell": """Create cell and add it to the row. @@ -397,6 +402,7 @@ class Row(Element): column_group=group, title=title, raw_title=raw_title, + only_excel=only_excel, no_excel=no_excel, ) @@ -406,6 +412,7 @@ class Row(Element): cell: "Cell", column_group: str | None = None, title: str | None = None, + only_excel: bool = False, no_excel: bool = False, raw_title: str | None = None, ) -> "Cell": @@ -414,10 +421,10 @@ class Row(Element): """ cell.data["group"] = column_group or "" 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) - if not no_excel: - self.table.raw_column_ids.append(col_id) + if not no_excel and col_id not in self.table.raw_column_ids: + self.table.raw_column_ids.append(col_id) self.table.insert_group(column_group) if column_group is not None: @@ -425,7 +432,12 @@ class Row(Element): if title is not None: 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 diff --git a/app/tables/visu_assiduites.py b/app/tables/visu_assiduites.py index 8c99f493..af3895e7 100644 --- a/app/tables/visu_assiduites.py +++ b/app/tables/visu_assiduites.py @@ -6,14 +6,15 @@ """Liste simple d'étudiants """ - +import datetime from flask import g, url_for from app import log from app.models import FormSemestre, Identite, Justificatif 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_utils as scu +import app.scodoc.sco_assiduites as scass +from app.scodoc.sco_exceptions import ScoValueError class TableAssi(tb.Table): @@ -39,7 +40,13 @@ class TableAssi(tb.Table): ): self.rows: list["RowAssi"] = [] # juste pour que VSCode nous aide sur .rows 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_modimpls = formsemestre_modimpls if convert_values: @@ -97,6 +104,20 @@ class RowAssi(tb.Row): bilan_etud = url_for( "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( "nom_disp", "Nom", diff --git a/app/views/assiduites.py b/app/views/assiduites.py index 7ce10e55..bd9536a9 100644 --- a/app/views/assiduites.py +++ b/app/views/assiduites.py @@ -1440,7 +1440,6 @@ def visu_assi_group(): formsemestre_modimpls=formsemestre_modimpls, convert_values=(fmt == "html"), ) - # Export en XLS if fmt.startswith("xls"): return scu.send_file(