1
0
forked from ScoDoc/ScoDoc

annotations

This commit is contained in:
Emmanuel Viennet 2022-07-03 08:31:01 +02:00
parent 0bf636814d
commit 835234779f
2 changed files with 46 additions and 33 deletions

View File

@ -52,7 +52,8 @@ from reportlab.platypus import Paragraph
from reportlab.lib import styles from reportlab.lib import styles
import flask import flask
from flask import url_for, g, redirect, request from flask import flash, redirect, url_for
from flask import g, request
from app.comp import res_sem from app.comp import res_sem
from app.comp.res_compat import NotesTableCompat from app.comp.res_compat import NotesTableCompat
@ -798,7 +799,7 @@ def descrform_pvjury(sem):
def formsemestre_lettres_individuelles(formsemestre_id, group_ids=[]): def formsemestre_lettres_individuelles(formsemestre_id, group_ids=[]):
"Lettres avis jury en PDF" "Lettres avis jury en PDF"
sem = sco_formsemestre.get_formsemestre(formsemestre_id) formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id)
if not group_ids: if not group_ids:
# tous les inscrits du semestre # tous les inscrits du semestre
group_ids = [sco_groups.get_default_group(formsemestre_id)] group_ids = [sco_groups.get_default_group(formsemestre_id)]
@ -814,10 +815,15 @@ def formsemestre_lettres_individuelles(formsemestre_id, group_ids=[]):
cssstyles=sco_groups_view.CSSSTYLES, cssstyles=sco_groups_view.CSSSTYLES,
init_qtip=True, init_qtip=True,
), ),
"""<p class="help">Utiliser cette page pour éditer des versions provisoires des PV. f"""<p class="help">Utiliser cette page pour éditer des versions provisoires des PV.
<span class="fontred">Il est recommandé d'archiver les versions définitives: <a href="formsemestre_archive?formsemestre_id=%s">voir cette page</a></span></p> <span class="fontred">Il est recommandé d'archiver les versions définitives: <a
""" href="{url_for(
% formsemestre_id, "notes.formsemestre_archive",
scodoc_dept=g.scodoc_dept,
formsemestre_id=formsemestre_id,
)}"
>voir cette page</a></span></p>
""",
] ]
F = html_sco_header.sco_footer() F = html_sco_header.sco_footer()
descr = descrform_lettres_individuelles() descr = descrform_lettres_individuelles()
@ -842,7 +848,11 @@ def formsemestre_lettres_individuelles(formsemestre_id, group_ids=[]):
return "\n".join(H) + "\n" + tf[1] + F return "\n".join(H) + "\n" + tf[1] + F
elif tf[0] == -1: elif tf[0] == -1:
return flask.redirect( return flask.redirect(
"formsemestre_pvjury?formsemestre_id=%s" % (formsemestre_id) url_for(
"notes.formsemestre_pvjury",
scodoc_dept=g.scodoc_dept,
formsemestre_id=formsemestre_id,
)
) )
else: else:
# submit # submit
@ -860,15 +870,17 @@ def formsemestre_lettres_individuelles(formsemestre_id, group_ids=[]):
finally: finally:
PDFLOCK.release() PDFLOCK.release()
if not pdfdoc: if not pdfdoc:
flash("Aucun étudiant n'a de décision de jury !")
return flask.redirect( return flask.redirect(
"formsemestre_status?formsemestre_id={}&head_message=Aucun%20%C3%A9tudiant%20n%27a%20de%20d%C3%A9cision%20de%20jury".format( url_for(
formsemestre_id "notes.formsemestre_status",
scodoc_dept=g.scodoc_dept,
formsemestre_id=formsemestre_id,
) )
) )
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
dt = time.strftime("%Y-%m-%d")
groups_filename = "-" + groups_infos.groups_filename groups_filename = "-" + groups_infos.groups_filename
filename = "lettres-%s%s-%s.pdf" % (sem["titre_num"], groups_filename, dt) filename = f"""lettres-{formsemestre.titre_num()}{groups_filename}-{time.strftime("%Y-%m-%d")}.pdf"""
return scu.sendPDFFile(pdfdoc, filename) return scu.sendPDFFile(pdfdoc, filename)

View File

@ -45,13 +45,14 @@ from flask import g
import app.scodoc.sco_utils as scu import app.scodoc.sco_utils as scu
from app.scodoc import sco_bulletins_pdf from app.scodoc import sco_bulletins_pdf
from app.scodoc import sco_codes_parcours from app.scodoc import sco_codes_parcours
from app.scodoc import sco_etud
from app.scodoc import sco_formsemestre from app.scodoc import sco_formsemestre
from app.scodoc import sco_pdf from app.scodoc import sco_pdf
from app.scodoc import sco_preferences from app.scodoc import sco_preferences
from app.scodoc import sco_etud
import sco_version
from app.scodoc.sco_logos import find_logo from app.scodoc.sco_logos import find_logo
from app.scodoc.sco_parcours_dut import SituationEtudParcours
from app.scodoc.sco_pdf import SU from app.scodoc.sco_pdf import SU
import sco_version
LOGO_FOOTER_ASPECT = scu.CONFIG.LOGO_FOOTER_ASPECT # XXX A AUTOMATISER LOGO_FOOTER_ASPECT = scu.CONFIG.LOGO_FOOTER_ASPECT # XXX A AUTOMATISER
LOGO_FOOTER_HEIGHT = scu.CONFIG.LOGO_FOOTER_HEIGHT * mm LOGO_FOOTER_HEIGHT = scu.CONFIG.LOGO_FOOTER_HEIGHT * mm
@ -62,7 +63,7 @@ LOGO_HEADER_HEIGHT = scu.CONFIG.LOGO_HEADER_HEIGHT * mm
LOGO_HEADER_WIDTH = LOGO_HEADER_HEIGHT * scu.CONFIG.LOGO_HEADER_ASPECT LOGO_HEADER_WIDTH = LOGO_HEADER_HEIGHT * scu.CONFIG.LOGO_HEADER_ASPECT
def pageFooter(canvas, doc, logo, preferences, with_page_numbers=True): def page_footer(canvas, doc, logo, preferences, with_page_numbers=True):
"Add footer on page" "Add footer on page"
width = doc.pagesize[0] # - doc.pageTemplate.left_p - doc.pageTemplate.right_p width = doc.pagesize[0] # - doc.pageTemplate.left_p - doc.pageTemplate.right_p
foot = Frame( foot = Frame(
@ -78,24 +79,24 @@ def pageFooter(canvas, doc, logo, preferences, with_page_numbers=True):
showBoundary=0, showBoundary=0,
) )
LeftFootStyle = reportlab.lib.styles.ParagraphStyle({}) left_foot_style = reportlab.lib.styles.ParagraphStyle({})
LeftFootStyle.fontName = preferences["SCOLAR_FONT"] left_foot_style.fontName = preferences["SCOLAR_FONT"]
LeftFootStyle.fontSize = preferences["SCOLAR_FONT_SIZE_FOOT"] left_foot_style.fontSize = preferences["SCOLAR_FONT_SIZE_FOOT"]
LeftFootStyle.leftIndent = 0 left_foot_style.leftIndent = 0
LeftFootStyle.firstLineIndent = 0 left_foot_style.firstLineIndent = 0
LeftFootStyle.alignment = TA_RIGHT left_foot_style.alignment = TA_RIGHT
RightFootStyle = reportlab.lib.styles.ParagraphStyle({}) right_foot_style = reportlab.lib.styles.ParagraphStyle({})
RightFootStyle.fontName = preferences["SCOLAR_FONT"] right_foot_style.fontName = preferences["SCOLAR_FONT"]
RightFootStyle.fontSize = preferences["SCOLAR_FONT_SIZE_FOOT"] right_foot_style.fontSize = preferences["SCOLAR_FONT_SIZE_FOOT"]
RightFootStyle.alignment = TA_RIGHT right_foot_style.alignment = TA_RIGHT
p = sco_pdf.makeParas( p = sco_pdf.makeParas(
"""<para>%s</para><para>%s</para>""" f"""<para>{preferences["INSTITUTION_NAME"]}</para><para>{
% (preferences["INSTITUTION_NAME"], preferences["INSTITUTION_ADDRESS"]), preferences["INSTITUTION_ADDRESS"]}</para>""",
LeftFootStyle, left_foot_style,
) )
np = Paragraph('<para fontSize="14">%d</para>' % doc.page, RightFootStyle) np = Paragraph(f'<para fontSize="14">{doc.page}</para>', right_foot_style)
tabstyle = TableStyle( tabstyle = TableStyle(
[ [
("LEFTPADDING", (0, 0), (-1, -1), 0), ("LEFTPADDING", (0, 0), (-1, -1), 0),
@ -123,7 +124,7 @@ def pageFooter(canvas, doc, logo, preferences, with_page_numbers=True):
canvas.restoreState() canvas.restoreState()
def pageHeader(canvas, doc, logo, preferences, only_on_first_page=False): def page_header(canvas, doc, logo, preferences, only_on_first_page=False):
if only_on_first_page and int(doc.page) > 1: if only_on_first_page and int(doc.page) > 1:
return return
height = doc.pagesize[1] height = doc.pagesize[1]
@ -260,7 +261,7 @@ class CourrierIndividuelTemplate(PageTemplate):
# ---- Header/Footer # ---- Header/Footer
if self.with_header: if self.with_header:
pageHeader( page_header(
canvas, canvas,
doc, doc,
self.logo_header, self.logo_header,
@ -268,7 +269,7 @@ class CourrierIndividuelTemplate(PageTemplate):
self.header_only_on_first_page, self.header_only_on_first_page,
) )
if self.with_footer: if self.with_footer:
pageFooter( page_footer(
canvas, canvas,
doc, doc,
self.logo_footer, self.logo_footer,
@ -427,7 +428,7 @@ def pdf_lettre_individuelle(sem, decision, etud, params, signature=None):
""" """
# #
formsemestre_id = sem["formsemestre_id"] formsemestre_id = sem["formsemestre_id"]
Se = decision["Se"] Se: SituationEtudParcours = decision["Se"]
t, s = _descr_jury(sem, Se.parcours_validated() or not Se.semestre_non_terminal) t, s = _descr_jury(sem, Se.parcours_validated() or not Se.semestre_non_terminal)
objects = [] objects = []
style = reportlab.lib.styles.ParagraphStyle({}) style = reportlab.lib.styles.ParagraphStyle({})