forked from ScoDoc/ScoDoc
Option de config globale pour imposer saisie du mail institutionnel dans le formulaire
This commit is contained in:
parent
e61ec5e04e
commit
ac9b5722cf
@ -77,6 +77,9 @@ class ScoDocConfigurationForm(FlaskForm):
|
||||
Attention: si ce champ peut aussi être défini dans chaque département.""",
|
||||
validators=[Optional(), Email()],
|
||||
)
|
||||
user_require_email_institutionnel = BooleanField(
|
||||
"imposer la saisie du mail institutionnel dans le formulaire de création utilisateur"
|
||||
)
|
||||
disable_bul_pdf = BooleanField(
|
||||
"interdire les exports des bulletins en PDF (déconseillé)"
|
||||
)
|
||||
@ -99,6 +102,7 @@ def configuration():
|
||||
"month_debut_periode2": ScoDocSiteConfig.get_month_debut_periode2(),
|
||||
"email_from_addr": ScoDocSiteConfig.get("email_from_addr"),
|
||||
"disable_bul_pdf": ScoDocSiteConfig.is_bul_pdf_disabled(),
|
||||
"user_require_email_institutionnel": ScoDocSiteConfig.is_user_require_email_institutionnel_enabled(),
|
||||
}
|
||||
)
|
||||
if request.method == "POST" and (
|
||||
@ -151,6 +155,18 @@ def configuration():
|
||||
"Exports PDF "
|
||||
+ ("désactivés" if form_scodoc.data["disable_bul_pdf"] else "réactivés")
|
||||
)
|
||||
if ScoDocSiteConfig.set(
|
||||
"user_require_email_institutionnel",
|
||||
"on" if form_scodoc.data["user_require_email_institutionnel"] else "",
|
||||
):
|
||||
flash(
|
||||
(
|
||||
"impose"
|
||||
if form_scodoc.data["user_require_email_institutionnel"]
|
||||
else "n'impose pas"
|
||||
)
|
||||
+ " la saisie du mail institutionnel des utilisateurs"
|
||||
)
|
||||
return redirect(url_for("scodoc.index"))
|
||||
|
||||
return render_template(
|
||||
|
@ -95,6 +95,7 @@ class ScoDocSiteConfig(db.Model):
|
||||
"month_debut_annee_scolaire": int,
|
||||
"month_debut_periode2": int,
|
||||
"disable_bul_pdf": bool,
|
||||
"user_require_email_institutionnel": bool,
|
||||
# CAS
|
||||
"cas_enable": bool,
|
||||
"cas_server": str,
|
||||
@ -243,6 +244,14 @@ class ScoDocSiteConfig(db.Model):
|
||||
cfg = ScoDocSiteConfig.query.filter_by(name="enable_entreprises").first()
|
||||
return cfg is not None and cfg.value
|
||||
|
||||
@classmethod
|
||||
def is_user_require_email_institutionnel_enabled(cls) -> bool:
|
||||
"""True si impose saisie email_institutionnel"""
|
||||
cfg = ScoDocSiteConfig.query.filter_by(
|
||||
name="user_require_email_institutionnel"
|
||||
).first()
|
||||
return cfg is not None and cfg.value
|
||||
|
||||
@classmethod
|
||||
def is_bul_pdf_disabled(cls) -> bool:
|
||||
"""True si on interdit les exports PDF des bulltins"""
|
||||
@ -250,36 +259,14 @@ class ScoDocSiteConfig(db.Model):
|
||||
return cfg is not None and cfg.value
|
||||
|
||||
@classmethod
|
||||
def enable_entreprises(cls, enabled=True) -> bool:
|
||||
def enable_entreprises(cls, enabled: bool = True) -> bool:
|
||||
"""Active (ou déactive) le module entreprises. True si changement."""
|
||||
if enabled != ScoDocSiteConfig.is_entreprises_enabled():
|
||||
cfg = ScoDocSiteConfig.query.filter_by(name="enable_entreprises").first()
|
||||
if cfg is None:
|
||||
cfg = ScoDocSiteConfig(
|
||||
name="enable_entreprises", value="on" if enabled else ""
|
||||
)
|
||||
else:
|
||||
cfg.value = "on" if enabled else ""
|
||||
db.session.add(cfg)
|
||||
db.session.commit()
|
||||
return True
|
||||
return False
|
||||
return cls.set("enable_entreprises", "on" if enabled else "")
|
||||
|
||||
@classmethod
|
||||
def disable_bul_pdf(cls, enabled=True) -> bool:
|
||||
"""Interedit (ou autorise) les exports PDF. True si changement."""
|
||||
if enabled != ScoDocSiteConfig.is_bul_pdf_disabled():
|
||||
cfg = ScoDocSiteConfig.query.filter_by(name="disable_bul_pdf").first()
|
||||
if cfg is None:
|
||||
cfg = ScoDocSiteConfig(
|
||||
name="disable_bul_pdf", value="on" if enabled else ""
|
||||
)
|
||||
else:
|
||||
cfg.value = "on" if enabled else ""
|
||||
db.session.add(cfg)
|
||||
db.session.commit()
|
||||
return True
|
||||
return False
|
||||
"""Interdit (ou autorise) les exports PDF. True si changement."""
|
||||
return cls.set("disable_bul_pdf", "on" if enabled else "")
|
||||
|
||||
@classmethod
|
||||
def get(cls, name: str, default: str = "") -> str:
|
||||
@ -298,9 +285,10 @@ class ScoDocSiteConfig(db.Model):
|
||||
if cfg is None:
|
||||
cfg = ScoDocSiteConfig(name=name, value=value_str)
|
||||
else:
|
||||
cfg.value = str(value or "")
|
||||
cfg.value = value_str
|
||||
current_app.logger.info(
|
||||
f"""ScoDocSiteConfig: recording {cfg.name}='{cfg.value[:32]}...'"""
|
||||
f"""ScoDocSiteConfig: recording {cfg.name}='{cfg.value[:32]}{
|
||||
'...' if len(cfg.value)>32 else ''}'"""
|
||||
)
|
||||
db.session.add(cfg)
|
||||
db.session.commit()
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
<div class="sco_help"><div style="font-style: normal;">
|
||||
Heure: <b><tt>{{ time.strftime("%d/%m/%Y %H:%M") }}</tt></b>
|
||||
<em>(devrait être l'heure de votre montre, sinon vérifiez que le serveur est bien en heure légale de votre pays)</em>
|
||||
<em>(devrait être l'heure aux montres des étudiants, sinon vérifiez que le serveur est bien en heure légale de votre pays)</em>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -382,6 +382,9 @@ def create_user_form(user_name=None, edit=0, all_roles=True):
|
||||
cas_allow_login_default = int(
|
||||
bool(ScoDocSiteConfig.get("cas_allow_for_new_users"))
|
||||
)
|
||||
require_email_institutionnel = (
|
||||
ScoDocSiteConfig.is_user_require_email_institutionnel_enabled()
|
||||
)
|
||||
descr += [
|
||||
(
|
||||
"email",
|
||||
@ -444,9 +447,13 @@ def create_user_form(user_name=None, edit=0, all_roles=True):
|
||||
{
|
||||
"title": "e-mail institutionnel",
|
||||
"input_type": "text",
|
||||
"explanation": "facultatif" if not edit_only_roles else "",
|
||||
"explanation": (
|
||||
"requis" if require_email_institutionnel else "facultatif"
|
||||
)
|
||||
if not edit_only_roles
|
||||
else "",
|
||||
"size": 36,
|
||||
"allow_null": True,
|
||||
"allow_null": not require_email_institutionnel,
|
||||
"readonly": edit_only_roles,
|
||||
},
|
||||
),
|
||||
|
Loading…
Reference in New Issue
Block a user