diff --git a/app/scodoc/sco_bulletins.py b/app/scodoc/sco_bulletins.py
index 46101451..c4b10c01 100644
--- a/app/scodoc/sco_bulletins.py
+++ b/app/scodoc/sco_bulletins.py
@@ -32,7 +32,7 @@ import email
import time
from flask import g, request
-from flask import render_template, url_for
+from flask import flash, render_template, url_for
from flask_login import current_user
from app import email
@@ -817,7 +817,8 @@ def formsemestre_bulletinetud(
if format not in {"html", "pdfmail"}:
filename = scu.bul_filename(formsemestre, etud, format)
return scu.send_file(bulletin, filename, mime=scu.get_mime_suffix(format)[0])
-
+ elif format == "pdfmail":
+ return ""
H = [
_formsemestre_bulletinetud_header_html(etud, formsemestre, format, version),
bulletin,
@@ -851,7 +852,6 @@ def do_formsemestre_bulletinetud(
etudid: int,
version="long", # short, long, selectedevals
format=None,
- nohtml=False,
xml_with_decisions=False, # force décisions dans XML
force_publishing=False, # force publication meme si semestre non publié sur "portail"
prefer_mail_perso=False, # mails envoyés sur adresse perso si non vide
@@ -918,13 +918,6 @@ 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 !")
- if nohtml:
- htm = "" # speed up if html version not needed
- else:
- htm, _ = sco_bulletins_generator.make_formsemestre_bulletinetud(
- I, version=version, format="html"
- )
-
pdfdata, filename = sco_bulletins_generator.make_formsemestre_bulletinetud(
I, version=version, format="pdf"
)
@@ -935,28 +928,15 @@ def do_formsemestre_bulletinetud(
recipient_addr = etud.get("email", "") or etud.get("emailperso", "")
if not recipient_addr:
- if nohtml:
- h = "" # permet de compter les non-envois
- else:
- h = (
- "
%s n'a pas d'adresse e-mail !
"
- % etud["nomprenom"]
- ) + htm
- return h, I["filigranne"]
- #
- mail_bulletin(formsemestre.id, I, pdfdata, filename, recipient_addr)
- emaillink = '%s' % (
- recipient_addr,
- recipient_addr,
- )
- return (
- ('Message mail envoyé à %s
' % (emaillink))
- + htm,
- I["filigranne"],
- )
+ flash(f"{etud['nomprenom']} n'a pas d'adresse e-mail !")
+ return False, I["filigranne"]
+ else:
+ mail_bulletin(formsemestre.id, I, pdfdata, filename, recipient_addr)
+ flash(f"mail envoyé à {recipient_addr}")
- else:
- raise ValueError("do_formsemestre_bulletinetud: invalid format (%s)" % format)
+ return True, I["filigranne"]
+
+ raise ValueError("do_formsemestre_bulletinetud: invalid format (%s)" % format)
def mail_bulletin(formsemestre_id, I, pdfdata, filename, recipient_addr):
diff --git a/app/scodoc/sco_bulletins_standard.py b/app/scodoc/sco_bulletins_standard.py
index e42a3884..e7c92ad7 100644
--- a/app/scodoc/sco_bulletins_standard.py
+++ b/app/scodoc/sco_bulletins_standard.py
@@ -49,6 +49,7 @@ Balises img: actuellement interdites.
from reportlab.platypus import KeepTogether, Paragraph, Spacer, Table
from reportlab.lib.units import cm, mm
from reportlab.lib.colors import Color, blue
+from app.models import FormSemestre
from app.scodoc.sco_exceptions import ScoBugCatcher
import app.scodoc.sco_utils as scu
@@ -271,7 +272,7 @@ class BulletinGeneratorStandard(sco_bulletins_generator.BulletinGenerator):
)
def build_bulletin_table(self):
- """Génère la table centrale du bulletin de notes
+ """Génère la table centrale du bulletin de notes classique (pas BUT)
Renvoie: col_keys, P, pdf_style, col_widths
- col_keys: nom des colonnes de la table (clés)
- table: liste de dicts de chaines de caractères
@@ -417,10 +418,7 @@ class BulletinGeneratorStandard(sco_bulletins_generator.BulletinGenerator):
# Chaque UE:
for ue in I["ues"]:
ue_type = None
- try:
- coef_ue = ue["coef_ue_txt"] if prefs["bul_show_ue_coef"] else ""
- except TypeError as exc:
- raise ScoBugCatcher(f"ue={ue!r}") from exc
+ coef_ue = ue["coef_ue_txt"] if prefs["bul_show_ue_coef"] else ""
ue_descr = ue["ue_descr_txt"]
rowstyle = ""
diff --git a/app/views/notes.py b/app/views/notes.py
index 7a9e5067..fd39f271 100644
--- a/app/views/notes.py
+++ b/app/views/notes.py
@@ -36,7 +36,7 @@ import time
from xml.etree import ElementTree
import flask
-from flask import abort, flash, jsonify, render_template, url_for
+from flask import abort, flash, jsonify, redirect, render_template, url_for
from flask import current_app, g, request
from flask_login import current_user
from werkzeug.utils import redirect
@@ -359,7 +359,7 @@ def formsemestre_bulletinetud(
)
if format == "oldjson":
format = "json"
- return sco_bulletins.formsemestre_bulletinetud(
+ r = sco_bulletins.formsemestre_bulletinetud(
etud,
formsemestre_id=formsemestre_id,
format=format,
@@ -368,6 +368,16 @@ def formsemestre_bulletinetud(
force_publishing=force_publishing,
prefer_mail_perso=prefer_mail_perso,
)
+ if format == "pdfmail":
+ return redirect(
+ url_for(
+ "notes.formsemestre_bulletinetud",
+ scodoc_dept=g.scodoc_dept,
+ etudid=etud.id,
+ formsemestre_id=formsemestre_id,
+ )
+ )
+ return r
sco_publish(
@@ -1955,23 +1965,22 @@ def formsemestre_bulletins_mailetuds(
)
# Make each bulletin
- nb_send = 0
+ nb_sent = 0
for etudid in etudids:
- h, _ = sco_bulletins.do_formsemestre_bulletinetud(
+ sent, _ = sco_bulletins.do_formsemestre_bulletinetud(
formsemestre,
etudid,
version=version,
prefer_mail_perso=prefer_mail_perso,
format="pdfmail",
- nohtml=True,
)
- if h:
- nb_send += 1
+ if sent:
+ nb_sent += 1
#
return (
html_sco_header.sco_header()
+ '%d bulletins sur %d envoyés par mail !
continuer
'
- % (nb_send, len(etudids), formsemestre_id)
+ % (nb_sent, len(etudids), formsemestre_id)
+ html_sco_header.sco_footer()
)
diff --git a/tools/check_network.py b/tools/check_network.py
new file mode 100644
index 00000000..ceaafa5e
--- /dev/null
+++ b/tools/check_network.py
@@ -0,0 +1,10 @@
+# test simple de connectivité pour tests
+
+import requests
+import sco_version
+import app.scodoc.sco_utils as scu
+
+response = requests.get(scu.SCO_UP2DATE + "/" + sco_version.SCOVERSION)
+
+print(response.status_code)
+print(response.text)