forked from ScoDoc/ScoDoc
Envoi par mail des bulletins PDF courts
This commit is contained in:
parent
0f860f912c
commit
689b8610bf
@ -345,8 +345,8 @@ class BulletinBUT:
|
||||
- Si force_publishing, rempli le bulletin même si bul_hide_xml est vrai
|
||||
(bulletins non publiés).
|
||||
"""
|
||||
if version not in scu.BULLETINS_VERSIONS:
|
||||
raise ScoValueError("version de bulletin demandée invalide")
|
||||
if version not in scu.BULLETINS_VERSIONS_BUT:
|
||||
raise ScoValueError("bulletin_etud: version de bulletin demandée invalide")
|
||||
res = self.res
|
||||
formsemestre = res.formsemestre
|
||||
etat_inscription = etud.inscription_etat(formsemestre.id)
|
||||
|
@ -83,12 +83,16 @@ def bulletin_but(formsemestre_id: int, etudid: int = None, fmt="html"):
|
||||
)
|
||||
|
||||
|
||||
def bulletin_but_court_pdf_frag(etud: Identite, formsemestre: FormSemestre) -> bytes:
|
||||
def bulletin_but_court_pdf_frag(
|
||||
etud: Identite, formsemestre: FormSemestre, stand_alone=False
|
||||
) -> bytes:
|
||||
"""Le code PDF d'un bulletin BUT court, à intégrer dans un document
|
||||
(pour les classeurs de tous les bulletins)
|
||||
"""
|
||||
args = _build_bulletin_but_infos(etud, formsemestre)
|
||||
return bulletin_but_court_pdf.make_bulletin_but_court_pdf(args, stand_alone=False)
|
||||
return bulletin_but_court_pdf.make_bulletin_but_court_pdf(
|
||||
args, stand_alone=stand_alone
|
||||
)
|
||||
|
||||
|
||||
def _build_bulletin_but_infos(
|
||||
|
@ -346,7 +346,9 @@ def do_formsemestre_archive(
|
||||
)
|
||||
|
||||
if bul_version not in scu.BULLETINS_VERSIONS:
|
||||
raise ScoValueError("version de bulletin demandée invalide")
|
||||
raise ScoValueError(
|
||||
"do_formsemestre_archive: version de bulletin demandée invalide"
|
||||
)
|
||||
formsemestre = FormSemestre.get_formsemestre(formsemestre_id)
|
||||
res: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
|
||||
sem_archive_id = formsemestre_id
|
||||
|
@ -985,6 +985,8 @@ def do_formsemestre_bulletinetud(
|
||||
où bul est str ou bytes au format demandé (html, pdf, pdfmail, pdfpart, xml, json)
|
||||
et filigranne est un message à placer en "filigranne" (eg "Provisoire").
|
||||
"""
|
||||
from app.but import bulletin_but_court
|
||||
|
||||
fmt = fmt or "html"
|
||||
if fmt == "xml":
|
||||
bul = sco_bulletins_xml.make_xml_formsemestre_bulletinetud(
|
||||
@ -1045,9 +1047,19 @@ def do_formsemestre_bulletinetud(
|
||||
if not can_send_bulletin_by_mail(formsemestre.id):
|
||||
raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !")
|
||||
|
||||
pdfdata, filename = sco_bulletins_generator.make_formsemestre_bulletin_etud(
|
||||
bul_dict, etud=etud, formsemestre=formsemestre, version=version, fmt="pdf"
|
||||
)
|
||||
if version == "butcourt":
|
||||
pdfdata = bulletin_but_court.bulletin_but_court_pdf_frag(
|
||||
etud, formsemestre, stand_alone=True
|
||||
)
|
||||
filename = scu.bul_filename(formsemestre, etud, prefix="bul-court")
|
||||
else:
|
||||
pdfdata, filename = sco_bulletins_generator.make_formsemestre_bulletin_etud(
|
||||
bul_dict,
|
||||
etud=etud,
|
||||
formsemestre=formsemestre,
|
||||
version=version,
|
||||
fmt="pdf",
|
||||
)
|
||||
|
||||
if prefer_mail_perso:
|
||||
recipient_addr = (
|
||||
|
@ -222,7 +222,9 @@ def get_formsemestre_bulletins_pdf(formsemestre_id, version="selectedevals"):
|
||||
else scu.BULLETINS_VERSIONS
|
||||
)
|
||||
if version not in versions:
|
||||
raise ScoValueError("version de bulletin demandée invalide !")
|
||||
raise ScoValueError(
|
||||
"get_formsemestre_bulletins_pdf: version de bulletin demandée invalide !"
|
||||
)
|
||||
cached = sco_cache.SemBulletinsPDFCache.get(str(formsemestre_id) + "_" + version)
|
||||
if cached:
|
||||
return cached[1], cached[0]
|
||||
|
@ -288,7 +288,9 @@ def formsemestre_bulletinetud(
|
||||
):
|
||||
fmt = fmt or "html"
|
||||
if version not in scu.BULLETINS_VERSIONS_BUT:
|
||||
raise ScoValueError("version de bulletin demandée invalide")
|
||||
raise ScoValueError(
|
||||
"formsemestre_bulletinetud: version de bulletin demandée invalide"
|
||||
)
|
||||
if not isinstance(etudid, int):
|
||||
raise ScoInvalidIdType("formsemestre_bulletinetud: etudid must be an integer !")
|
||||
if formsemestre_id is not None and not isinstance(formsemestre_id, int):
|
||||
@ -1881,13 +1883,14 @@ _EXPL_BULL = """Versions des bulletins:
|
||||
@scodoc7func
|
||||
def formsemestre_bulletins_pdf_choice(formsemestre_id, version=None):
|
||||
"""Choix version puis envoi classeur bulletins pdf"""
|
||||
formsemestre = FormSemestre.get_formsemestre(formsemestre_id)
|
||||
if version:
|
||||
pdfdoc, filename = sco_bulletins_pdf.get_formsemestre_bulletins_pdf(
|
||||
formsemestre_id, version=version
|
||||
)
|
||||
return scu.sendPDFFile(pdfdoc, filename)
|
||||
return formsemestre_bulletins_choice(
|
||||
formsemestre_id,
|
||||
return _formsemestre_bulletins_choice(
|
||||
formsemestre,
|
||||
title="Choisir la version des bulletins à générer",
|
||||
explanation=_EXPL_BULL,
|
||||
)
|
||||
@ -1900,7 +1903,7 @@ def formsemestre_bulletins_pdf_choice(formsemestre_id, version=None):
|
||||
def etud_bulletins_pdf(etudid, version="selectedevals"):
|
||||
"Publie tous les bulletins d'un etudiants dans un classeur PDF"
|
||||
if version not in scu.BULLETINS_VERSIONS:
|
||||
raise ScoValueError("version de bulletin demandée invalide")
|
||||
raise ScoValueError("etud_bulletins_pdf: version de bulletin demandée invalide")
|
||||
pdfdoc, filename = sco_bulletins_pdf.get_etud_bulletins_pdf(etudid, version=version)
|
||||
return scu.sendPDFFile(pdfdoc, filename)
|
||||
|
||||
@ -1927,15 +1930,20 @@ def formsemestre_bulletins_mailetuds_choice(
|
||||
prefer_mail_perso=prefer_mail_perso,
|
||||
)
|
||||
)
|
||||
|
||||
formsemestre = FormSemestre.get_formsemestre(formsemestre_id)
|
||||
expl_bull = """Versions des bulletins:
|
||||
<ul>
|
||||
<li><b>courte</b>: moyennes des modules</li>
|
||||
<li><b>intermédiaire</b>: moyennes des modules et notes des évaluations sélectionnées</li>
|
||||
<li><b>complète</b>: toutes les notes</li>
|
||||
<ul>"""
|
||||
return formsemestre_bulletins_choice(
|
||||
formsemestre_id,
|
||||
"""
|
||||
if formsemestre.formation.is_apc():
|
||||
expl_bull += """
|
||||
<li><b>courte spéciale BUT</b>: un résumé en une page pour les BUTs</li>
|
||||
"""
|
||||
expl_bull += "</ul>"
|
||||
return _formsemestre_bulletins_choice(
|
||||
formsemestre,
|
||||
title="Choisir la version des bulletins à envoyer par mail",
|
||||
explanation="""Chaque étudiant (non démissionnaire ni défaillant)
|
||||
ayant une adresse mail connue de ScoDoc
|
||||
@ -1947,23 +1955,24 @@ def formsemestre_bulletins_mailetuds_choice(
|
||||
|
||||
|
||||
# not published
|
||||
def formsemestre_bulletins_choice(
|
||||
formsemestre_id, title="", explanation="", choose_mail=False
|
||||
def _formsemestre_bulletins_choice(
|
||||
formsemestre: FormSemestre, title="", explanation="", choose_mail=False
|
||||
):
|
||||
"""Choix d'une version de bulletin"""
|
||||
versions = (
|
||||
scu.BULLETINS_VERSIONS_BUT
|
||||
if formsemestre.formation.is_apc()
|
||||
else scu.BULLETINS_VERSIONS
|
||||
)
|
||||
H = [
|
||||
html_sco_header.html_sem_header(title),
|
||||
f"""
|
||||
<form name="f" method="GET" action="{request.base_url}">
|
||||
<input type="hidden" name="formsemestre_id" value="{formsemestre_id}"></input>
|
||||
<input type="hidden" name="formsemestre_id" value="{formsemestre.id}"></input>
|
||||
""",
|
||||
]
|
||||
H.append("""<select name="version" class="noprint">""")
|
||||
for version, description in (
|
||||
("short", "Version courte"),
|
||||
("selectedevals", "Version intermédiaire"),
|
||||
("long", "Version complète"),
|
||||
):
|
||||
for version, description in versions.items():
|
||||
H.append(f"""<option value="{version}">{description}</option>""")
|
||||
|
||||
H.append("""</select> <input type="submit" value="Générer"/>""")
|
||||
|
Loading…
Reference in New Issue
Block a user