Bulletins mails interdits - closes #810

This commit is contained in:
Emmanuel Viennet 2023-12-06 23:05:23 +01:00
parent dc0061fb92
commit 7b8d5cff4d
4 changed files with 19 additions and 16 deletions

View File

@ -370,7 +370,7 @@ def bulletin(
formsemestre_id : l'id d'un formsemestre formsemestre_id : l'id d'un formsemestre
code_type : "etudid", "nip" ou "ine" code_type : "etudid", "nip" ou "ine"
code : valeur du code INE, NIP ou etudid, selon code_type. 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). pdf : si spécifié, bulletin au format PDF (et non JSON).
Exemple de résultat : voir https://scodoc.org/ScoDoc9API/#bulletin Exemple de résultat : voir https://scodoc.org/ScoDoc9API/#bulletin

View File

@ -52,6 +52,7 @@ from app.models import (
FormSemestre, FormSemestre,
Identite, Identite,
ModuleImplInscription, ModuleImplInscription,
ScoDocSiteConfig,
) )
from app.scodoc.sco_permissions import Permission from app.scodoc.sco_permissions import Permission
from app.scodoc.sco_exceptions import AccessDenied, ScoValueError from app.scodoc.sco_exceptions import AccessDenied, ScoValueError
@ -950,13 +951,13 @@ def formsemestre_bulletinetud(
def can_send_bulletin_by_mail(formsemestre_id): 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) sem = sco_formsemestre.get_formsemestre(formsemestre_id)
return ( return (
sco_preferences.get_preference("bul_mail_allowed_for_all", formsemestre_id) sco_preferences.get_preference("bul_mail_allowed_for_all", formsemestre_id)
or current_user.has_permission(Permission.EditFormSemestre) or current_user.has_permission(Permission.EditFormSemestre)
or current_user.id in sem["responsables"] or current_user.id in sem["responsables"]
) ) and not ScoDocSiteConfig.is_bul_pdf_disabled()
def do_formsemestre_bulletinetud( def do_formsemestre_bulletinetud(

View File

@ -35,8 +35,8 @@ from flask_login import current_user
from app import db, log from app import db, log
from app.but import cursus_but from app.but import cursus_but
from app.models.etudiants import Identite, make_etud_args from app.models.etudiants import make_etud_args
from app.models.formsemestre import FormSemestre from app.models import Identite, FormSemestre, ScoDocSiteConfig
from app.scodoc import html_sco_header from app.scodoc import html_sco_header
from app.scodoc import htmlutils from app.scodoc import htmlutils
from app.scodoc import sco_archives_etud from app.scodoc import sco_archives_etud
@ -307,15 +307,17 @@ def ficheEtud(etudid=None):
with_all_columns=False, with_all_columns=False,
a_url="Notes/", a_url="Notes/",
) )
info[ info["link_bul_pdf"] = (
"link_bul_pdf" """<span class="link_bul_pdf fontred">PDF interdits par l'admin.</span>"""
] = f""" if ScoDocSiteConfig.is_bul_pdf_disabled()
else f"""
<span class="link_bul_pdf"> <span class="link_bul_pdf">
<a class="stdlink" href="{ <a class="stdlink" href="{
url_for("notes.etud_bulletins_pdf", scodoc_dept=g.scodoc_dept, etudid=etudid) url_for("notes.etud_bulletins_pdf", scodoc_dept=g.scodoc_dept, etudid=etudid)
}">Tous les bulletins</a> }">Tous les bulletins</a>
</span> </span>
""" """
)
last_formsemestre: FormSemestre = db.session.get( last_formsemestre: FormSemestre = db.session.get(
FormSemestre, info["sems"][0]["formsemestre_id"] FormSemestre, info["sems"][0]["formsemestre_id"]
) )

View File

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