From 576383da8d81df0d0e93f3cb2c52f6010f21dd21 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Tue, 16 Jul 2024 14:55:57 +0200 Subject: [PATCH] Indique semestre dans sujet mail bulletin. Implements #954. --- app/scodoc/sco_bulletins.py | 32 ++++++++++++++++++++------------ sco_version.py | 2 +- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/app/scodoc/sco_bulletins.py b/app/scodoc/sco_bulletins.py index 2ca0632f3..9b776eb49 100644 --- a/app/scodoc/sco_bulletins.py +++ b/app/scodoc/sco_bulletins.py @@ -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: diff --git a/sco_version.py b/sco_version.py index 1f3a33211..9e616fdfb 100644 --- a/sco_version.py +++ b/sco_version.py @@ -1,7 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- -SCOVERSION = "9.7.1" +SCOVERSION = "9.7.2" SCONAME = "ScoDoc"