CAS: corrige formulaire config utilisateur (bug PB)

This commit is contained in:
Emmanuel Viennet 2023-02-28 22:55:15 +01:00
parent a7ada3a1d5
commit 7da076c1bf
2 changed files with 10 additions and 5 deletions

View File

@ -69,7 +69,7 @@ class User(UserMixin, db.Model):
) )
"Peut-on se logguer via le CAS ?" "Peut-on se logguer via le CAS ?"
cas_allow_scodoc_login = db.Column( cas_allow_scodoc_login = db.Column(
db.Boolean, default=True, server_default="false", nullable=False db.Boolean, default=False, server_default="false", nullable=False
) )
"""(not yet implemented XXX) """(not yet implemented XXX)
si CAS activé, peut-on se logguer sur ScoDoc directement ? si CAS activé, peut-on se logguer sur ScoDoc directement ?
@ -221,7 +221,7 @@ class User(UserMixin, db.Model):
data["email"] = self.email or "" data["email"] = self.email or ""
return data return data
def from_dict(self, data, new_user=False): def from_dict(self, data: dict, new_user=False):
"""Set users' attributes from given dict values. """Set users' attributes from given dict values.
Roles must be encoded as "roles_string", like "Ens_RT, Secr_CJ" Roles must be encoded as "roles_string", like "Ens_RT, Secr_CJ"
""" """
@ -233,11 +233,16 @@ class User(UserMixin, db.Model):
"email", "email",
"date_expiration", "date_expiration",
"cas_id", "cas_id",
"cas_allow_login",
"cas_allow_scodoc_login",
]: ]:
if field in data: if field in data:
setattr(self, field, data[field] or None) setattr(self, field, data[field] or None)
# required boolean fields
for field in [
"cas_allow_login",
"cas_allow_scodoc_login",
]:
setattr(self, field, data.get(field, False))
if new_user: if new_user:
if "user_name" in data: if "user_name" in data:
# never change name of existing users # never change name of existing users

View File

@ -800,7 +800,7 @@ var {field}_as = new bsn.AutoSuggest('{field}', {field}_opts);
elif input_type in ("radio", "menu", "checkbox", "boolcheckbox"): elif input_type in ("radio", "menu", "checkbox", "boolcheckbox"):
if input_type == "boolcheckbox": if input_type == "boolcheckbox":
labels = descr.get( labels = descr.get(
"labels", descr.get("allowed_values", ["oui", "non"]) "labels", descr.get("allowed_values", ["non", "oui"])
) )
_val = self.values[field] _val = self.values[field]
if isinstance(_val, bool): if isinstance(_val, bool):