Table jury: en excel, ajoute les adresses mail

This commit is contained in:
Emmanuel Viennet 2024-11-06 18:27:24 +01:00
parent 8135038edb
commit 815d5a71ae
3 changed files with 16 additions and 1 deletions

View File

@ -522,7 +522,7 @@ class Identite(models.ScoDocModel):
e_dict["date_naissance"] = ndb.DateISOtoDMY(e_dict.get("date_naissance", "")) e_dict["date_naissance"] = ndb.DateISOtoDMY(e_dict.get("date_naissance", ""))
e_dict["ne"] = self.e e_dict["ne"] = self.e
e_dict["nomprenom"] = self.nomprenom e_dict["nomprenom"] = self.nomprenom
adresse = self.adresses.first() adresse: Adresse = self.adresses.first()
if adresse: if adresse:
e_dict.update(adresse.to_dict(restrict=restrict)) e_dict.update(adresse.to_dict(restrict=restrict))
if with_inscriptions: if with_inscriptions:

View File

@ -33,8 +33,10 @@ import time
from xml.etree import ElementTree from xml.etree import ElementTree
from flask import abort, g, render_template, request, url_for from flask import abort, g, render_template, request, url_for
from flask_login import current_user
from app import log from app import log
from app.auth.models import Permission
from app.but import bulletin_but from app.but import bulletin_but
from app.comp import res_sem from app.comp import res_sem
from app.comp.res_common import ResultatsSemestre from app.comp.res_common import ResultatsSemestre
@ -507,6 +509,7 @@ def gen_formsemestre_recapcomplet_html_table(
def _gen_formsemestre_recapcomplet_table( def _gen_formsemestre_recapcomplet_table(
res: ResultatsSemestre, res: ResultatsSemestre,
include_email_addresses=False,
include_evaluations=False, include_evaluations=False,
mode_jury=False, mode_jury=False,
convert_values: bool = True, convert_values: bool = True,
@ -518,6 +521,7 @@ def _gen_formsemestre_recapcomplet_table(
table = table_class( table = table_class(
res, res,
convert_values=convert_values, convert_values=convert_values,
include_email_addresses=include_email_addresses,
include_evaluations=include_evaluations, include_evaluations=include_evaluations,
mode_jury=mode_jury, mode_jury=mode_jury,
read_only=not res.formsemestre.can_edit_jury(), read_only=not res.formsemestre.can_edit_jury(),
@ -539,8 +543,10 @@ def gen_formsemestre_recapcomplet_excel(
Attention: le tableau exporté depuis la page html est celui généré en js par DataTables, Attention: le tableau exporté depuis la page html est celui généré en js par DataTables,
et non celui-ci. et non celui-ci.
""" """
# En excel, ajoute les adresses mail, si on a le droit de les voir.
table = _gen_formsemestre_recapcomplet_table( table = _gen_formsemestre_recapcomplet_table(
res, res,
include_email_addresses=current_user.has_permission(Permission.ViewEtudData),
include_evaluations=include_evaluations, include_evaluations=include_evaluations,
mode_jury=mode_jury, mode_jury=mode_jury,
convert_values=False, convert_values=False,

View File

@ -51,6 +51,7 @@ class TableRecap(tb.Table):
self, self,
res: ResultatsSemestre, res: ResultatsSemestre,
convert_values=False, convert_values=False,
include_email_addresses=False,
include_evaluations=False, include_evaluations=False,
mode_jury=False, mode_jury=False,
row_class=None, row_class=None,
@ -61,6 +62,7 @@ class TableRecap(tb.Table):
self.rows: list["RowRecap"] = [] # juste pour que VSCode nous aide sur .rows self.rows: list["RowRecap"] = [] # juste pour que VSCode nous aide sur .rows
super().__init__(row_class=row_class or RowRecap, **kwargs) super().__init__(row_class=row_class or RowRecap, **kwargs)
self.res = res self.res = res
self.include_email_addresses = include_email_addresses
self.include_evaluations = include_evaluations self.include_evaluations = include_evaluations
self.mode_jury = mode_jury self.mode_jury = mode_jury
self.read_only = read_only # utilisé seulement dans sous-classes self.read_only = read_only # utilisé seulement dans sous-classes
@ -618,6 +620,13 @@ class RowRecap(tb.Row):
target=url_bulletin, target=url_bulletin,
target_attrs={"class": "etudinfo", "id": str(etud.id)}, target_attrs={"class": "etudinfo", "id": str(etud.id)},
) )
if self.table.include_email_addresses:
address = etud.adresses.first()
if address:
self.add_cell("email", "Email", address.email, "identite_detail")
self.add_cell(
"emailperso", "Email perso", address.emailperso, "identite_detail"
)
def add_abs(self): def add_abs(self):
"Ajoute les colonnes absences" "Ajoute les colonnes absences"