From 7da076c1bfc3b58ed527cc342a6d4b450c9e7fe6 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Tue, 28 Feb 2023 22:55:15 +0100 Subject: [PATCH] CAS: corrige formulaire config utilisateur (bug PB) --- app/auth/models.py | 13 +++++++++---- app/scodoc/TrivialFormulator.py | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/auth/models.py b/app/auth/models.py index d39b0274..18709de0 100644 --- a/app/auth/models.py +++ b/app/auth/models.py @@ -69,7 +69,7 @@ class User(UserMixin, db.Model): ) "Peut-on se logguer via le CAS ?" 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) si CAS activé, peut-on se logguer sur ScoDoc directement ? @@ -221,7 +221,7 @@ class User(UserMixin, db.Model): data["email"] = self.email or "" 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. Roles must be encoded as "roles_string", like "Ens_RT, Secr_CJ" """ @@ -233,11 +233,16 @@ class User(UserMixin, db.Model): "email", "date_expiration", "cas_id", - "cas_allow_login", - "cas_allow_scodoc_login", ]: if field in data: 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 "user_name" in data: # never change name of existing users diff --git a/app/scodoc/TrivialFormulator.py b/app/scodoc/TrivialFormulator.py index 0c7e3762..0e805f01 100644 --- a/app/scodoc/TrivialFormulator.py +++ b/app/scodoc/TrivialFormulator.py @@ -800,7 +800,7 @@ var {field}_as = new bsn.AutoSuggest('{field}', {field}_opts); elif input_type in ("radio", "menu", "checkbox", "boolcheckbox"): if input_type == "boolcheckbox": labels = descr.get( - "labels", descr.get("allowed_values", ["oui", "non"]) + "labels", descr.get("allowed_values", ["non", "oui"]) ) _val = self.values[field] if isinstance(_val, bool):