1
0
forked from ScoDoc/ScoDoc

Indique semestre dans sujet mail bulletin. Implements #954.

This commit is contained in:
Emmanuel Viennet 2024-07-16 14:55:57 +02:00
parent a25407565c
commit 576383da8d
2 changed files with 21 additions and 13 deletions

View File

@ -1102,7 +1102,9 @@ def do_formsemestre_bulletinetud(
flash(f"{etud.nomprenom} n'a pas d'adresse e-mail !")
return False, bul_dict["filigranne"]
else:
mail_bulletin(formsemestre.id, bul_dict, pdfdata, filename, recipient_addr)
mail_bulletin(
formsemestre, etud, bul_dict, pdfdata, filename, recipient_addr
)
flash(f"mail envoyé à {recipient_addr}")
return True, bul_dict["filigranne"]
@ -1110,22 +1112,28 @@ def do_formsemestre_bulletinetud(
raise ValueError(f"do_formsemestre_bulletinetud: invalid format ({fmt})")
def mail_bulletin(formsemestre_id, infos, pdfdata, filename, recipient_addr):
def mail_bulletin(
formsemestre: FormSemestre,
etud: Identite,
infos: dict,
pdfdata,
filename,
recipient_addr,
):
"""Send bulletin by email to etud
If bul_mail_list_abs pref is true, put list of absences in mail body (text).
"""
etud = infos["etud"]
webmaster = sco_preferences.get_preference("bul_mail_contact_addr", formsemestre_id)
webmaster = sco_preferences.get_preference("bul_mail_contact_addr", formsemestre.id)
dept = scu.unescape_html(
sco_preferences.get_preference("DeptName", formsemestre_id)
sco_preferences.get_preference("DeptName", formsemestre.id)
)
copy_addr = sco_preferences.get_preference("email_copy_bulletins", formsemestre_id)
intro_mail = sco_preferences.get_preference("bul_intro_mail", formsemestre_id)
copy_addr = sco_preferences.get_preference("email_copy_bulletins", formsemestre.id)
intro_mail = sco_preferences.get_preference("bul_intro_mail", formsemestre.id)
if intro_mail:
try:
hea = intro_mail % {
"nomprenom": etud["nomprenom"],
"nomprenom": etud.nom_prenom(),
"dept": dept,
"webmaster": webmaster,
}
@ -1139,12 +1147,12 @@ def mail_bulletin(formsemestre_id, infos, pdfdata, filename, recipient_addr):
if sco_preferences.get_preference("bul_mail_list_abs"):
from app.views.assiduites import generate_bul_list
etud_identite: Identite = Identite.get_etud(etud["etudid"])
form_semestre: FormSemestre = FormSemestre.get_formsemestre(formsemestre_id)
hea += "\n\n"
hea += generate_bul_list(etud_identite, form_semestre)
hea += generate_bul_list(etud, formsemestre)
subject = f"""Relevé de notes de {etud["nomprenom"]}"""
subject = f"""Relevé de notes du semestre {
formsemestre.semestre_id if formsemestre.semestre_id >= 0 else ''
} de {etud.nom_prenom()}"""
recipients = [recipient_addr]
sender = email.get_from_addr()
if copy_addr:

View File

@ -1,7 +1,7 @@
# -*- mode: python -*-
# -*- coding: utf-8 -*-
SCOVERSION = "9.7.1"
SCOVERSION = "9.7.2"
SCONAME = "ScoDoc"