Update opolka/ScoDoc from ScoDoc/ScoDoc #2

Merged
opolka merged 1272 commits from ScoDoc/ScoDoc:master into master 2024-05-27 09:11:04 +02:00
4 changed files with 21 additions and 0 deletions
Showing only changes of commit bd0df7c503 - Show all commits

View File

@ -40,6 +40,9 @@ class ConfigCASForm(FlaskForm):
cas_force = BooleanField( cas_force = BooleanField(
"Forcer l'utilisation de CAS (tous les utilisateurs seront redirigés vers le CAS)" "Forcer l'utilisation de CAS (tous les utilisateurs seront redirigés vers le CAS)"
) )
cas_allow_for_new_users = BooleanField(
"Par défaut, autoriser le CAS aux nouveaux utilisateurs"
)
cas_server = StringField( cas_server = StringField(
label="URL du serveur CAS", label="URL du serveur CAS",

View File

@ -17,6 +17,7 @@
{{ wtf.form_field(form.cas_enable) }} {{ wtf.form_field(form.cas_enable) }}
{{ wtf.form_field(form.cas_force) }} {{ wtf.form_field(form.cas_force) }}
{{ wtf.form_field(form.cas_allow_for_new_users) }}
{{ wtf.form_field(form.cas_server) }} {{ wtf.form_field(form.cas_server) }}
{{ wtf.form_field(form.cas_login_route) }} {{ wtf.form_field(form.cas_login_route) }}
{{ wtf.form_field(form.cas_logout_route) }} {{ wtf.form_field(form.cas_logout_route) }}

View File

@ -156,6 +156,13 @@ def config_cas():
flash("CAS " + ("activé" if form.data["cas_enable"] else "désactivé")) flash("CAS " + ("activé" if form.data["cas_enable"] else "désactivé"))
if ScoDocSiteConfig.set("cas_force", form.data["cas_force"]): if ScoDocSiteConfig.set("cas_force", form.data["cas_force"]):
flash("CAS " + ("forcé" if form.data["cas_force"] else "non forcé")) flash("CAS " + ("forcé" if form.data["cas_force"] else "non forcé"))
if ScoDocSiteConfig.set(
"cas_allow_for_new_users", form.data["cas_allow_for_new_users"]
):
flash(
f"""CAS {'' if form.data['cas_allow_for_new_users'] else 'non'
} autorisé par défaut aux nouveaux"""
)
if ScoDocSiteConfig.set("cas_server", form.data["cas_server"]): if ScoDocSiteConfig.set("cas_server", form.data["cas_server"]):
flash("URL du serveur CAS enregistrée") flash("URL du serveur CAS enregistrée")
if ScoDocSiteConfig.set("cas_login_route", form.data["cas_login_route"]): if ScoDocSiteConfig.set("cas_login_route", form.data["cas_login_route"]):
@ -182,6 +189,9 @@ def config_cas():
elif request.method == "GET": elif request.method == "GET":
form.cas_enable.data = ScoDocSiteConfig.get("cas_enable") form.cas_enable.data = ScoDocSiteConfig.get("cas_enable")
form.cas_force.data = ScoDocSiteConfig.get("cas_force") form.cas_force.data = ScoDocSiteConfig.get("cas_force")
form.cas_allow_for_new_users.data = ScoDocSiteConfig.get(
"cas_allow_for_new_users"
)
form.cas_server.data = ScoDocSiteConfig.get("cas_server") form.cas_server.data = ScoDocSiteConfig.get("cas_server")
form.cas_login_route.data = ScoDocSiteConfig.get("cas_login_route") form.cas_login_route.data = ScoDocSiteConfig.get("cas_login_route")
form.cas_logout_route.data = ScoDocSiteConfig.get("cas_logout_route") form.cas_logout_route.data = ScoDocSiteConfig.get("cas_logout_route")

View File

@ -371,6 +371,12 @@ def create_user_form(user_name=None, edit=0, all_roles=True):
) )
] ]
cas_enabled = ScoDocSiteConfig.is_cas_enabled() cas_enabled = ScoDocSiteConfig.is_cas_enabled()
if edit:
cas_allow_login_default = the_user.cas_allow_login
else:
cas_allow_login_default = int(
bool(ScoDocSiteConfig.get("cas_allow_for_new_users"))
)
descr += [ descr += [
( (
"email", "email",
@ -408,6 +414,7 @@ def create_user_form(user_name=None, edit=0, all_roles=True):
"explanation": """ si CAS est activé. "explanation": """ si CAS est activé.
Seul le super-administrateur peut changer ce réglage.""", Seul le super-administrateur peut changer ce réglage.""",
"enabled": current_user.is_administrator(), "enabled": current_user.is_administrator(),
"default": cas_allow_login_default,
}, },
), ),
( (