Fix some bugs: bul. but, modimpl_status

This commit is contained in:
Emmanuel Viennet 2023-09-02 15:53:30 +02:00 committed by iziram
parent 1692857b0e
commit 1fd54ade84
8 changed files with 62 additions and 29 deletions

View File

@ -36,7 +36,7 @@ from app.decorators import (
) )
from app.models import FormSemestre, FormSemestreInscription, Identite from app.models import FormSemestre, FormSemestreInscription, Identite
from app.scodoc.codes_cursus import UE_STANDARD from app.scodoc.codes_cursus import UE_STANDARD
from app.scodoc.sco_exceptions import ScoNoReferentielCompetences from app.scodoc.sco_exceptions import ScoNoReferentielCompetences, ScoValueError
from app.scodoc.sco_logos import find_logo from app.scodoc.sco_logos import find_logo
from app.scodoc.sco_permissions import Permission from app.scodoc.sco_permissions import Permission
import app.scodoc.sco_utils as scu import app.scodoc.sco_utils as scu
@ -63,12 +63,18 @@ def bulletin_but(formsemestre_id: int, etudid: int = None, fmt="html"):
.filter_by(etudid=etudid) .filter_by(etudid=etudid)
.first_or_404() .first_or_404()
) )
if not formsemestre.formation.is_apc():
raise ScoValueError("formation non BUT")
bulletins_sem = BulletinBUT(formsemestre) bulletins_sem = BulletinBUT(formsemestre)
if fmt == "pdf": if fmt == "pdf":
bul: dict = bulletins_sem.bulletin_etud_complet(etud) bul: dict = bulletins_sem.bulletin_etud_complet(etud)
else: # la même chose avec un peu moins d'infos else: # la même chose avec un peu moins d'infos
bul: dict = bulletins_sem.bulletin_etud(etud) bul: dict = bulletins_sem.bulletin_etud(etud)
decision_ues = {x["acronyme"]: x for x in bul["semestre"]["decision_ue"]} decision_ues = (
{x["acronyme"]: x for x in bul["semestre"]["decision_ue"]}
if "semestre" in bul
else {}
)
cursus = cursus_but.EtudCursusBUT(etud, formsemestre.formation) cursus = cursus_but.EtudCursusBUT(etud, formsemestre.formation)
refcomp = formsemestre.formation.referentiel_competence refcomp = formsemestre.formation.referentiel_competence
if refcomp is None: if refcomp is None:
@ -80,6 +86,7 @@ def bulletin_but(formsemestre_id: int, etudid: int = None, fmt="html"):
logo = find_logo(logoname="header", dept_id=g.scodoc_dept_id) logo = find_logo(logoname="header", dept_id=g.scodoc_dept_id)
ue_acronyms = bul["ues"].keys()
args = { args = {
"bul": bul, "bul": bul,
"cursus": cursus, "cursus": cursus,
@ -91,13 +98,15 @@ def bulletin_but(formsemestre_id: int, etudid: int = None, fmt="html"):
"title": f"Bul. {etud.nom_disp()} BUT (court)", "title": f"Bul. {etud.nom_disp()} BUT (court)",
"ue_validation_by_niveau": ue_validation_by_niveau, "ue_validation_by_niveau": ue_validation_by_niveau,
"ues_acronyms": [ "ues_acronyms": [
ue.acronyme for ue in bulletins_sem.res.ues if ue.type == UE_STANDARD ue.acronyme
for ue in bulletins_sem.res.ues
if ue.type == UE_STANDARD and ue.acronyme in ue_acronyms
], ],
} }
if fmt == "pdf": if fmt == "pdf":
filename = scu.bul_filename(formsemestre, etud, prefix="bul-but") filename = scu.bul_filename(formsemestre, etud, prefix="bul-but")
bul_pdf = bulletin_but_court_pdf.make_bulletin_but_court_pdf(**args) bul_pdf = bulletin_but_court_pdf.make_bulletin_but_court_pdf(**args)
return scu.sendPDFFile(bul_pdf, filename) return scu.sendPDFFile(bul_pdf, filename + ".pdf")
return render_template( return render_template(
"but/bulletin_court_page.j2", "but/bulletin_court_page.j2",

View File

@ -16,7 +16,7 @@ from flask_login import current_user
from reportlab.lib import styles from reportlab.lib import styles
from reportlab.lib.colors import black, white, Color from reportlab.lib.colors import black, white, Color
from reportlab.lib.enums import TA_CENTER from reportlab.lib.enums import TA_CENTER
from reportlab.lib.units import cm, mm from reportlab.lib.units import mm
from reportlab.platypus import Paragraph, Spacer, Table from reportlab.platypus import Paragraph, Spacer, Table
from app.but import cursus_but from app.but import cursus_but
@ -102,13 +102,15 @@ class BulletinGeneratorBUTCourt(BulletinGeneratorStandard):
self.style_base = styles.ParagraphStyle("style_base") self.style_base = styles.ParagraphStyle("style_base")
self.style_base.fontName = "Helvetica" self.style_base.fontName = "Helvetica"
self.style_base.fontSize = 9 self.style_base.fontSize = 9
self.style_base.firstLineIndent = 0
# écrase style defaut des bulletins
self.style_field = self.style_base
# Le nom/prénom de l'étudiant:
self.style_nom = styles.ParagraphStyle("style_nom", self.style_base) self.style_nom = styles.ParagraphStyle("style_nom", self.style_base)
self.style_nom.fontSize = 11 self.style_nom.fontSize = 11
self.style_nom.fontName = "Helvetica-Bold" self.style_nom.fontName = "Helvetica-Bold"
self.style_field = self.style_base # écrase style defaut buleltins
self.style_cell = styles.ParagraphStyle("style_cell", self.style_base) self.style_cell = styles.ParagraphStyle("style_cell", self.style_base)
self.style_cell.fontSize = 7 self.style_cell.fontSize = 7
self.style_cell.leading = 7 self.style_cell.leading = 7
@ -124,7 +126,7 @@ class BulletinGeneratorBUTCourt(BulletinGeneratorStandard):
self.style_niveaux.firstLineIndent = 0 self.style_niveaux.firstLineIndent = 0
self.style_niveaux.leftIndent = 1 self.style_niveaux.leftIndent = 1
self.style_niveaux.rightIndent = 1 self.style_niveaux.rightIndent = 1
self.style_niveaux.borderWidth = 1 self.style_niveaux.borderWidth = 0.5
self.style_niveaux.borderPadding = 2 self.style_niveaux.borderPadding = 2
self.style_niveaux.borderRadius = 2 self.style_niveaux.borderRadius = 2
self.style_niveaux_top = styles.ParagraphStyle( self.style_niveaux_top = styles.ParagraphStyle(
@ -162,6 +164,7 @@ class BulletinGeneratorBUTCourt(BulletinGeneratorStandard):
) # espace les lignes ) # espace les lignes
self.style_assiduite = self.style_cell self.style_assiduite = self.style_cell
self.style_signature = self.style_appreciations
# Géométrie page # Géométrie page
self.width_page_avail = 185 * mm # largeur utilisable self.width_page_avail = 185 * mm # largeur utilisable
@ -189,10 +192,16 @@ class BulletinGeneratorBUTCourt(BulletinGeneratorStandard):
appreciations = BulAppreciations.get_appreciations_list( appreciations = BulAppreciations.get_appreciations_list(
self.formsemestre.id, self.etud.id self.formsemestre.id, self.etud.id
) )
return [ return (
Spacer(1, 3 * mm), [
self.bul_appreciations_pdf(appreciations, style=self.style_appreciations), Spacer(1, 3 * mm),
] self.bul_appreciations_pdf(
appreciations, style=self.style_appreciations
),
]
if appreciations
else []
)
def bul_table(self, fmt=None) -> list: def bul_table(self, fmt=None) -> list:
"""Génère la table centrale du bulletin de notes """Génère la table centrale du bulletin de notes

View File

@ -117,6 +117,8 @@ class BulletinGenerator:
self.style_field.fontName = self.preferences["SCOLAR_FONT_BUL_FIELDS"] self.style_field.fontName = self.preferences["SCOLAR_FONT_BUL_FIELDS"]
self.style_field.fontSize = self.preferences["SCOLAR_FONT_SIZE"] self.style_field.fontSize = self.preferences["SCOLAR_FONT_SIZE"]
self.style_field.firstLineIndent = 0 self.style_field.firstLineIndent = 0
# Champ signatures
self.style_signature = self.style_field
# - Pour les cellules de table: # - Pour les cellules de table:
self.CellStyle = reportlab.lib.styles.ParagraphStyle({}) self.CellStyle = reportlab.lib.styles.ParagraphStyle({})
self.CellStyle.fontSize = self.preferences["SCOLAR_FONT_SIZE"] self.CellStyle.fontSize = self.preferences["SCOLAR_FONT_SIZE"]

View File

@ -263,7 +263,7 @@ class BulletinGeneratorStandard(sco_bulletins_generator.BulletinGenerator):
sco_bulletins_pdf.process_field( sco_bulletins_pdf.process_field(
self.preferences["bul_pdf_sig_left"], self.preferences["bul_pdf_sig_left"],
self.infos, self.infos,
self.style_field, self.style_signature,
field_name="bul_pdf_sig_left", field_name="bul_pdf_sig_left",
) )
] ]
@ -275,7 +275,7 @@ class BulletinGeneratorStandard(sco_bulletins_generator.BulletinGenerator):
sco_bulletins_pdf.process_field( sco_bulletins_pdf.process_field(
self.preferences["bul_pdf_sig_right"], self.preferences["bul_pdf_sig_right"],
self.infos, self.infos,
self.style_field, self.style_signature,
field_name="bul_pdf_sig_right", field_name="bul_pdf_sig_right",
) )
) )

View File

@ -127,8 +127,12 @@ def moduleimpl_evaluation_menu(evaluation: Evaluation, nbnotes: int = 0) -> str:
"args": { "args": {
"group_ids": group_id, "group_ids": group_id,
"desc": evaluation.description or "", "desc": evaluation.description or "",
"date_debut": evaluation.date_debut.isoformat(), "date_debut": evaluation.date_debut.isoformat()
"date_fin": evaluation.date_fin.isoformat(), if evaluation.date_debut
else "",
"date_fin": evaluation.date_fin.isoformat()
if evaluation.date_fin
else "",
}, },
"enabled": evaluation.date_debut is not None, "enabled": evaluation.date_debut is not None,
}, },

View File

@ -42,20 +42,22 @@
format='pdf', format='pdf',
version=version, version=version,
)}}">{{scu.ICON_PDF|safe}}</a> )}}">{{scu.ICON_PDF|safe}}</a>
<a style="margin-left: 20px;" {% if formsemestre.formation.is_apc() %}
href="{{url_for( <a style="margin-left: 20px;" class="stdlink"
'notes.bulletin_but_html', href="{{url_for(
scodoc_dept=g.scodoc_dept, 'notes.bulletin_but_html',
formsemestre_id=formsemestre.id, scodoc_dept=g.scodoc_dept,
etudid=etud.id formsemestre_id=formsemestre.id,
)}}">version courte spéciale BUT</a> etudid=etud.id
)}}">version courte spéciale BUT</a>
{% endif %}
</span> </span>
</div> </div>
</form> </form>
</div> </div>
{% if not is_apc %} {% if not is_apc %}
<div class="bull_photo"><a href="{{ <div class="bull_photo"><a href="{{
url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etud.id) url_for('scolar.ficheEtud', scodoc_dept=g.scodoc_dept, etudid=etud.id)
}}">{{etud.photo_html(title="fiche de " + etud["nom"])|safe}}</a> }}">{{etud.photo_html(title="fiche de " + etud["nom"])|safe}}</a>
</div> </div>
{% endif %} {% endif %}

View File

@ -39,10 +39,17 @@
{%- endmacro %} {%- endmacro %}
{% block app_content %} {% block app_content %}
<p><a href="{{url_for( <p>
<a href="{{url_for(
'notes.bulletin_but_pdf', scodoc_dept=g.scodoc_dept, etudid=etud.id, 'notes.bulletin_but_pdf', scodoc_dept=g.scodoc_dept, etudid=etud.id,
formsemestre_id=formsemestre.id formsemestre_id=formsemestre.id
)}}" class="stdlink">version pdf {{scu.ICON_PDF|safe}}</a> )}}" class="stdlink">version pdf {{scu.ICON_PDF|safe}}</a>
<a style="margin-left: 32px;"
href="{{url_for(
'notes.formsemestre_bulletinetud',
scodoc_dept=g.scodoc_dept, etudid=etud.id,
formsemestre_id=formsemestre.id
)}}" class="stdlink">version complète</a>
</p> </p>
<div class="but_bul_court"> <div class="but_bul_court">
@ -57,9 +64,9 @@
</div> </div>
<div id="logo"> <div id="logo">
{% if logo %} <a href="{{
{{logo.html()|safe}} url_for('scolar.ficheEtud', scodoc_dept=g.scodoc_dept, etudid=etud.id)
{% endif %} }}">{{etud.photo_html()|safe}}</a>
</div> </div>
{% if bul.options.show_abs %} {% if bul.options.show_abs %}

View File

@ -1,7 +1,7 @@
# -*- mode: python -*- # -*- mode: python -*-
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
SCOVERSION = "9.6.16" SCOVERSION = "9.6.17"
SCONAME = "ScoDoc" SCONAME = "ScoDoc"