From 835234779f15317ea6556c429ddfc97e0d700ee9 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sun, 3 Jul 2022 08:31:01 +0200 Subject: [PATCH] annotations --- app/scodoc/sco_pvjury.py | 36 ++++++++++++++++++++++----------- app/scodoc/sco_pvpdf.py | 43 ++++++++++++++++++++-------------------- 2 files changed, 46 insertions(+), 33 deletions(-) diff --git a/app/scodoc/sco_pvjury.py b/app/scodoc/sco_pvjury.py index 3cba7a933..9b374b8e3 100644 --- a/app/scodoc/sco_pvjury.py +++ b/app/scodoc/sco_pvjury.py @@ -52,7 +52,8 @@ from reportlab.platypus import Paragraph from reportlab.lib import styles 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.res_compat import NotesTableCompat @@ -798,7 +799,7 @@ def descrform_pvjury(sem): def formsemestre_lettres_individuelles(formsemestre_id, group_ids=[]): "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: # tous les inscrits du semestre 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, init_qtip=True, ), - """

Utiliser cette page pour éditer des versions provisoires des PV. - Il est recommandé d'archiver les versions définitives: voir cette page

- """ - % formsemestre_id, + f"""

Utiliser cette page pour éditer des versions provisoires des PV. + Il est recommandé d'archiver les versions définitives: voir cette page

+ """, ] F = html_sco_header.sco_footer() descr = descrform_lettres_individuelles() @@ -842,7 +848,11 @@ def formsemestre_lettres_individuelles(formsemestre_id, group_ids=[]): return "\n".join(H) + "\n" + tf[1] + F elif tf[0] == -1: 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: # submit @@ -860,15 +870,17 @@ def formsemestre_lettres_individuelles(formsemestre_id, group_ids=[]): finally: PDFLOCK.release() if not pdfdoc: + flash("Aucun étudiant n'a de décision de jury !") return flask.redirect( - "formsemestre_status?formsemestre_id={}&head_message=Aucun%20%C3%A9tudiant%20n%27a%20de%20d%C3%A9cision%20de%20jury".format( - formsemestre_id + url_for( + "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 - 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) diff --git a/app/scodoc/sco_pvpdf.py b/app/scodoc/sco_pvpdf.py index b2515895c..8ef1c12cc 100644 --- a/app/scodoc/sco_pvpdf.py +++ b/app/scodoc/sco_pvpdf.py @@ -45,13 +45,14 @@ from flask import g import app.scodoc.sco_utils as scu from app.scodoc import sco_bulletins_pdf from app.scodoc import sco_codes_parcours +from app.scodoc import sco_etud from app.scodoc import sco_formsemestre from app.scodoc import sco_pdf 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_parcours_dut import SituationEtudParcours from app.scodoc.sco_pdf import SU +import sco_version LOGO_FOOTER_ASPECT = scu.CONFIG.LOGO_FOOTER_ASPECT # XXX A AUTOMATISER 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 -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" width = doc.pagesize[0] # - doc.pageTemplate.left_p - doc.pageTemplate.right_p foot = Frame( @@ -78,24 +79,24 @@ def pageFooter(canvas, doc, logo, preferences, with_page_numbers=True): showBoundary=0, ) - LeftFootStyle = reportlab.lib.styles.ParagraphStyle({}) - LeftFootStyle.fontName = preferences["SCOLAR_FONT"] - LeftFootStyle.fontSize = preferences["SCOLAR_FONT_SIZE_FOOT"] - LeftFootStyle.leftIndent = 0 - LeftFootStyle.firstLineIndent = 0 - LeftFootStyle.alignment = TA_RIGHT - RightFootStyle = reportlab.lib.styles.ParagraphStyle({}) - RightFootStyle.fontName = preferences["SCOLAR_FONT"] - RightFootStyle.fontSize = preferences["SCOLAR_FONT_SIZE_FOOT"] - RightFootStyle.alignment = TA_RIGHT + left_foot_style = reportlab.lib.styles.ParagraphStyle({}) + left_foot_style.fontName = preferences["SCOLAR_FONT"] + left_foot_style.fontSize = preferences["SCOLAR_FONT_SIZE_FOOT"] + left_foot_style.leftIndent = 0 + left_foot_style.firstLineIndent = 0 + left_foot_style.alignment = TA_RIGHT + right_foot_style = reportlab.lib.styles.ParagraphStyle({}) + right_foot_style.fontName = preferences["SCOLAR_FONT"] + right_foot_style.fontSize = preferences["SCOLAR_FONT_SIZE_FOOT"] + right_foot_style.alignment = TA_RIGHT p = sco_pdf.makeParas( - """%s%s""" - % (preferences["INSTITUTION_NAME"], preferences["INSTITUTION_ADDRESS"]), - LeftFootStyle, + f"""{preferences["INSTITUTION_NAME"]}{ + preferences["INSTITUTION_ADDRESS"]}""", + left_foot_style, ) - np = Paragraph('%d' % doc.page, RightFootStyle) + np = Paragraph(f'{doc.page}', right_foot_style) tabstyle = TableStyle( [ ("LEFTPADDING", (0, 0), (-1, -1), 0), @@ -123,7 +124,7 @@ def pageFooter(canvas, doc, logo, preferences, with_page_numbers=True): 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: return height = doc.pagesize[1] @@ -260,7 +261,7 @@ class CourrierIndividuelTemplate(PageTemplate): # ---- Header/Footer if self.with_header: - pageHeader( + page_header( canvas, doc, self.logo_header, @@ -268,7 +269,7 @@ class CourrierIndividuelTemplate(PageTemplate): self.header_only_on_first_page, ) if self.with_footer: - pageFooter( + page_footer( canvas, doc, self.logo_footer, @@ -427,7 +428,7 @@ def pdf_lettre_individuelle(sem, decision, etud, params, signature=None): """ # 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) objects = [] style = reportlab.lib.styles.ParagraphStyle({})