From 7b8d5cff4dc41a41fef355b6499e1ed2eda4b8a7 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Wed, 6 Dec 2023 23:05:23 +0100 Subject: [PATCH] Bulletins mails interdits - closes #810 --- app/api/etudiants.py | 2 +- app/scodoc/sco_bulletins.py | 5 +++-- app/scodoc/sco_page_etud.py | 26 ++++++++++++++------------ sco_version.py | 2 +- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/app/api/etudiants.py b/app/api/etudiants.py index 6d0ec9e8..05ebb045 100755 --- a/app/api/etudiants.py +++ b/app/api/etudiants.py @@ -370,7 +370,7 @@ def bulletin( formsemestre_id : l'id d'un formsemestre code_type : "etudid", "nip" ou "ine" code : valeur du code INE, NIP ou etudid, selon code_type. - version : type de bulletin (par défaut, "long"): short, long, selectedevals, butcourt + version : type de bulletin (par défaut, "selectedevals"): short, long, selectedevals, butcourt pdf : si spécifié, bulletin au format PDF (et non JSON). Exemple de résultat : voir https://scodoc.org/ScoDoc9API/#bulletin diff --git a/app/scodoc/sco_bulletins.py b/app/scodoc/sco_bulletins.py index 82d8da5a..9ac41e6d 100644 --- a/app/scodoc/sco_bulletins.py +++ b/app/scodoc/sco_bulletins.py @@ -52,6 +52,7 @@ from app.models import ( FormSemestre, Identite, ModuleImplInscription, + ScoDocSiteConfig, ) from app.scodoc.sco_permissions import Permission from app.scodoc.sco_exceptions import AccessDenied, ScoValueError @@ -950,13 +951,13 @@ def formsemestre_bulletinetud( def can_send_bulletin_by_mail(formsemestre_id): - """True if current user is allowed to send a bulletin by mail""" + """True if current user is allowed to send a bulletin (pdf) by mail""" sem = sco_formsemestre.get_formsemestre(formsemestre_id) return ( sco_preferences.get_preference("bul_mail_allowed_for_all", formsemestre_id) or current_user.has_permission(Permission.EditFormSemestre) or current_user.id in sem["responsables"] - ) + ) and not ScoDocSiteConfig.is_bul_pdf_disabled() def do_formsemestre_bulletinetud( diff --git a/app/scodoc/sco_page_etud.py b/app/scodoc/sco_page_etud.py index d86229ee..010273d4 100644 --- a/app/scodoc/sco_page_etud.py +++ b/app/scodoc/sco_page_etud.py @@ -35,8 +35,8 @@ from flask_login import current_user from app import db, log from app.but import cursus_but -from app.models.etudiants import Identite, make_etud_args -from app.models.formsemestre import FormSemestre +from app.models.etudiants import make_etud_args +from app.models import Identite, FormSemestre, ScoDocSiteConfig from app.scodoc import html_sco_header from app.scodoc import htmlutils from app.scodoc import sco_archives_etud @@ -235,7 +235,7 @@ def ficheEtud(etudid=None): info[ "modifadresse" ] = f"""modifier adresse""" else: @@ -282,7 +282,7 @@ def ficheEtud(etudid=None): grlinks.append( f"""{gr_name} """ @@ -307,15 +307,17 @@ def ficheEtud(etudid=None): with_all_columns=False, a_url="Notes/", ) - info[ - "link_bul_pdf" - ] = f""" + info["link_bul_pdf"] = ( + """PDF interdits par l'admin.""" + if ScoDocSiteConfig.is_bul_pdf_disabled() + else f""" Tous les bulletins """ + ) last_formsemestre: FormSemestre = db.session.get( FormSemestre, info["sems"][0]["formsemestre_id"] ) @@ -333,11 +335,11 @@ def ficheEtud(etudid=None): info[ "link_inscrire_ailleurs" ] = f"""Inscrire à un autre semestre Éditer toutes décisions de jury """ @@ -381,7 +383,7 @@ def ficheEtud(etudid=None): ) author = sco_users.user_info(a["author"]) alist.append( - f"""Le {a['date']} par {author['prenomnom']} : + f"""Le {a['date']} par {author['prenomnom']} : {a['comment']}{a['dellink']} """ ) @@ -514,7 +516,7 @@ def ficheEtud(etudid=None): scu=scu, )}