From f547b800a18094ed48ff4386c44f95eb3f8fd39d Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Thu, 28 Sep 2023 17:30:36 +0200 Subject: [PATCH] Formulaires anciens: allow_null n'accepte plus de champs blancs --- app/scodoc/TrivialFormulator.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/scodoc/TrivialFormulator.py b/app/scodoc/TrivialFormulator.py index b673a3eb2d..b0334ae78c 100644 --- a/app/scodoc/TrivialFormulator.py +++ b/app/scodoc/TrivialFormulator.py @@ -237,7 +237,7 @@ class TF(object): def setdefaultvalues(self): "set default values and convert numbers to strings" - for (field, descr) in self.formdescription: + for field, descr in self.formdescription: # special case for boolcheckbox if descr.get("input_type", None) == "boolcheckbox" and self.submitted(): if field not in self.values: @@ -278,7 +278,7 @@ class TF(object): "check values. Store .result and returns msg" ok = 1 msg = [] - for (field, descr) in self.formdescription: + for field, descr in self.formdescription: val = self.values[field] # do not check "unckecked" items if descr.get("withcheckbox", False): @@ -287,7 +287,7 @@ class TF(object): # null values allow_null = descr.get("allow_null", True) if not allow_null: - if val == "" or val == None: + if val is None or (isinstance(val, str) and not val.strip()): msg.append( "Le champ '%s' doit ĂȘtre renseignĂ©" % descr.get("title", field) ) @@ -871,7 +871,7 @@ var {field}_as = new bsn.AutoSuggest('{field}', {field}_opts); def _ReadOnlyVersion(self, formdescription): "Generate HTML for read-only view of the form" R = [''] - for (field, descr) in formdescription: + for field, descr in formdescription: R.append(self._ReadOnlyElement(field, descr)) R.append("
") return R