forked from ScoDoc/DocScoDoc
API: bulletins PDF sans signatures
This commit is contained in:
parent
88b06f11d0
commit
abcb3d0fd2
@ -219,6 +219,10 @@ def etudiant_formsemestres(etudid: int = None, nip: int = None, ine: int = None)
|
|||||||
"/etudiant/<string:code_type>/<string:code>/formsemestre/<int:formsemestre_id>/bulletin/<string:version>/pdf",
|
"/etudiant/<string:code_type>/<string:code>/formsemestre/<int:formsemestre_id>/bulletin/<string:version>/pdf",
|
||||||
defaults={"pdf": True},
|
defaults={"pdf": True},
|
||||||
)
|
)
|
||||||
|
@bp.route(
|
||||||
|
"/etudiant/<string:code_type>/<string:code>/formsemestre/<int:formsemestre_id>/bulletin/<string:version>/pdf/nosig",
|
||||||
|
defaults={"pdf": True, "with_img_signatures_pdf": False},
|
||||||
|
)
|
||||||
@api_web_bp.route(
|
@api_web_bp.route(
|
||||||
"/etudiant/<string:code_type>/<string:code>/formsemestre/<int:formsemestre_id>/bulletin",
|
"/etudiant/<string:code_type>/<string:code>/formsemestre/<int:formsemestre_id>/bulletin",
|
||||||
)
|
)
|
||||||
@ -229,6 +233,10 @@ def etudiant_formsemestres(etudid: int = None, nip: int = None, ine: int = None)
|
|||||||
"/etudiant/<string:code_type>/<string:code>/formsemestre/<int:formsemestre_id>/bulletin/<string:version>/pdf",
|
"/etudiant/<string:code_type>/<string:code>/formsemestre/<int:formsemestre_id>/bulletin/<string:version>/pdf",
|
||||||
defaults={"pdf": True},
|
defaults={"pdf": True},
|
||||||
)
|
)
|
||||||
|
@api_web_bp.route(
|
||||||
|
"/etudiant/<string:code_type>/<string:code>/formsemestre/<int:formsemestre_id>/bulletin/<string:version>/pdf/nosig",
|
||||||
|
defaults={"pdf": True, "with_img_signatures_pdf": False},
|
||||||
|
)
|
||||||
@scodoc
|
@scodoc
|
||||||
@permission_required(Permission.ScoView)
|
@permission_required(Permission.ScoView)
|
||||||
def bulletin(
|
def bulletin(
|
||||||
@ -237,6 +245,7 @@ def bulletin(
|
|||||||
formsemestre_id: int = None,
|
formsemestre_id: int = None,
|
||||||
version: str = "long",
|
version: str = "long",
|
||||||
pdf: bool = False,
|
pdf: bool = False,
|
||||||
|
with_img_signatures_pdf: bool = True,
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Retourne le bulletin d'un étudiant en fonction de son id et d'un semestre donné
|
Retourne le bulletin d'un étudiant en fonction de son id et d'un semestre donné
|
||||||
@ -276,7 +285,11 @@ def bulletin(
|
|||||||
return json_error(404, message="etudiant inexistant")
|
return json_error(404, message="etudiant inexistant")
|
||||||
if pdf:
|
if pdf:
|
||||||
pdf_response, _ = do_formsemestre_bulletinetud(
|
pdf_response, _ = do_formsemestre_bulletinetud(
|
||||||
formsemestre, etud.id, version=version, format="pdf"
|
formsemestre,
|
||||||
|
etud.id,
|
||||||
|
version=version,
|
||||||
|
format="pdf",
|
||||||
|
with_img_signatures_pdf=with_img_signatures_pdf,
|
||||||
)
|
)
|
||||||
return pdf_response
|
return pdf_response
|
||||||
return sco_bulletins.get_formsemestre_bulletin_etud_json(
|
return sco_bulletins.get_formsemestre_bulletin_etud_json(
|
||||||
|
@ -951,9 +951,10 @@ def do_formsemestre_bulletinetud(
|
|||||||
etudid: int,
|
etudid: int,
|
||||||
version="long", # short, long, selectedevals
|
version="long", # short, long, selectedevals
|
||||||
format=None,
|
format=None,
|
||||||
xml_with_decisions=False, # force décisions dans XML
|
xml_with_decisions: bool = False,
|
||||||
force_publishing=False, # force publication meme si semestre non publié sur "portail"
|
force_publishing: bool = False,
|
||||||
prefer_mail_perso=False, # mails envoyés sur adresse perso si non vide
|
prefer_mail_perso: bool = False,
|
||||||
|
with_img_signatures_pdf: bool = True,
|
||||||
):
|
):
|
||||||
"""Génère le bulletin au format demandé.
|
"""Génère le bulletin au format demandé.
|
||||||
Utilisé pour:
|
Utilisé pour:
|
||||||
@ -961,6 +962,12 @@ def do_formsemestre_bulletinetud(
|
|||||||
- le format "oldjson" (les json sont générés à part, voir get_formsemestre_bulletin_etud_json)
|
- le format "oldjson" (les json sont générés à part, voir get_formsemestre_bulletin_etud_json)
|
||||||
- les formats PDF, XML et mail pdf (toutes formations)
|
- les formats PDF, XML et mail pdf (toutes formations)
|
||||||
|
|
||||||
|
Options:
|
||||||
|
- xml_with_decisions: force décisions dans XML
|
||||||
|
- force_publishing: force publication meme si semestre non publié sur "portail"
|
||||||
|
- prefer_mail_perso: mails envoyés sur adresse perso si non vide
|
||||||
|
- with_img_signatures_pdf: si faux, ne met pas les signatures dans le footer PDF.
|
||||||
|
|
||||||
Résultat: (bul, filigranne)
|
Résultat: (bul, filigranne)
|
||||||
où bul est str ou bytes au format demandé (html, pdf, pdfmail, pdfpart, xml, json)
|
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").
|
et filigranne est un message à placer en "filigranne" (eg "Provisoire").
|
||||||
@ -1009,6 +1016,7 @@ def do_formsemestre_bulletinetud(
|
|||||||
version=version,
|
version=version,
|
||||||
format="pdf",
|
format="pdf",
|
||||||
stand_alone=(format != "pdfpart"),
|
stand_alone=(format != "pdfpart"),
|
||||||
|
with_img_signatures_pdf=with_img_signatures_pdf,
|
||||||
)
|
)
|
||||||
if format == "pdf":
|
if format == "pdf":
|
||||||
return (
|
return (
|
||||||
|
@ -88,6 +88,7 @@ class BulletinGenerator:
|
|||||||
version="long",
|
version="long",
|
||||||
filigranne=None,
|
filigranne=None,
|
||||||
server_name=None,
|
server_name=None,
|
||||||
|
with_img_signatures_pdf: bool = True,
|
||||||
):
|
):
|
||||||
from app.scodoc import sco_preferences
|
from app.scodoc import sco_preferences
|
||||||
|
|
||||||
@ -98,6 +99,7 @@ class BulletinGenerator:
|
|||||||
self.version = version
|
self.version = version
|
||||||
self.filigranne = filigranne
|
self.filigranne = filigranne
|
||||||
self.server_name = server_name
|
self.server_name = server_name
|
||||||
|
self.with_img_signatures_pdf = with_img_signatures_pdf
|
||||||
# Store preferences for convenience:
|
# Store preferences for convenience:
|
||||||
formsemestre_id = self.infos["formsemestre_id"]
|
formsemestre_id = self.infos["formsemestre_id"]
|
||||||
self.preferences = sco_preferences.SemPreferences(formsemestre_id)
|
self.preferences = sco_preferences.SemPreferences(formsemestre_id)
|
||||||
@ -249,6 +251,7 @@ def make_formsemestre_bulletinetud(
|
|||||||
version=None, # short, long, selectedevals
|
version=None, # short, long, selectedevals
|
||||||
format="pdf", # html, pdf
|
format="pdf", # html, pdf
|
||||||
stand_alone=True,
|
stand_alone=True,
|
||||||
|
with_img_signatures_pdf: bool = True,
|
||||||
):
|
):
|
||||||
"""Bulletin de notes
|
"""Bulletin de notes
|
||||||
|
|
||||||
@ -277,9 +280,7 @@ def make_formsemestre_bulletinetud(
|
|||||||
gen_class = bulletin_get_class(bul_class_name)
|
gen_class = bulletin_get_class(bul_class_name)
|
||||||
|
|
||||||
if gen_class is None:
|
if gen_class is None:
|
||||||
raise ValueError(
|
raise ValueError(f"Type de bulletin PDF invalide (paramètre: {bul_class_name})")
|
||||||
"Type de bulletin PDF invalide (paramètre: %s)" % bul_class_name
|
|
||||||
)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
PDFLOCK.acquire()
|
PDFLOCK.acquire()
|
||||||
@ -289,6 +290,7 @@ def make_formsemestre_bulletinetud(
|
|||||||
version=version,
|
version=version,
|
||||||
filigranne=infos["filigranne"],
|
filigranne=infos["filigranne"],
|
||||||
server_name=request.url_root,
|
server_name=request.url_root,
|
||||||
|
with_img_signatures_pdf=with_img_signatures_pdf,
|
||||||
)
|
)
|
||||||
if format not in bul_generator.supported_formats:
|
if format not in bul_generator.supported_formats:
|
||||||
# use standard generator
|
# use standard generator
|
||||||
@ -304,6 +306,7 @@ def make_formsemestre_bulletinetud(
|
|||||||
version=version,
|
version=version,
|
||||||
filigranne=infos["filigranne"],
|
filigranne=infos["filigranne"],
|
||||||
server_name=request.url_root,
|
server_name=request.url_root,
|
||||||
|
with_img_signatures_pdf=with_img_signatures_pdf,
|
||||||
)
|
)
|
||||||
|
|
||||||
data = bul_generator.generate(format=format, stand_alone=stand_alone)
|
data = bul_generator.generate(format=format, stand_alone=stand_alone)
|
||||||
|
@ -213,7 +213,7 @@ class BulletinGeneratorStandard(sco_bulletins_generator.BulletinGenerator):
|
|||||||
"""
|
"""
|
||||||
show_left = self.preferences["bul_show_sig_left"]
|
show_left = self.preferences["bul_show_sig_left"]
|
||||||
show_right = self.preferences["bul_show_sig_right"]
|
show_right = self.preferences["bul_show_sig_right"]
|
||||||
if show_left or show_right:
|
if self.with_img_signatures_pdf and (show_left or show_right):
|
||||||
if show_left:
|
if show_left:
|
||||||
L = [
|
L = [
|
||||||
[
|
[
|
||||||
|
Loading…
Reference in New Issue
Block a user