Skip to content
Snippets Groups Projects
Commit f547b800 authored by Emmanuel Viennet's avatar Emmanuel Viennet
Browse files

Formulaires anciens: allow_null n'accepte plus de champs blancs

parent f333975e
Branches
No related tags found
No related merge requests found
...@@ -237,7 +237,7 @@ class TF(object): ...@@ -237,7 +237,7 @@ class TF(object):
def setdefaultvalues(self): def setdefaultvalues(self):
"set default values and convert numbers to strings" "set default values and convert numbers to strings"
for (field, descr) in self.formdescription: for field, descr in self.formdescription:
# special case for boolcheckbox # special case for boolcheckbox
if descr.get("input_type", None) == "boolcheckbox" and self.submitted(): if descr.get("input_type", None) == "boolcheckbox" and self.submitted():
if field not in self.values: if field not in self.values:
...@@ -278,7 +278,7 @@ class TF(object): ...@@ -278,7 +278,7 @@ class TF(object):
"check values. Store .result and returns msg" "check values. Store .result and returns msg"
ok = 1 ok = 1
msg = [] msg = []
for (field, descr) in self.formdescription: for field, descr in self.formdescription:
val = self.values[field] val = self.values[field]
# do not check "unckecked" items # do not check "unckecked" items
if descr.get("withcheckbox", False): if descr.get("withcheckbox", False):
...@@ -287,7 +287,7 @@ class TF(object): ...@@ -287,7 +287,7 @@ class TF(object):
# null values # null values
allow_null = descr.get("allow_null", True) allow_null = descr.get("allow_null", True)
if not allow_null: if not allow_null:
if val == "" or val == None: if val is None or (isinstance(val, str) and not val.strip()):
msg.append( msg.append(
"Le champ '%s' doit être renseigné" % descr.get("title", field) "Le champ '%s' doit être renseigné" % descr.get("title", field)
) )
...@@ -871,7 +871,7 @@ var {field}_as = new bsn.AutoSuggest('{field}', {field}_opts); ...@@ -871,7 +871,7 @@ var {field}_as = new bsn.AutoSuggest('{field}', {field}_opts);
def _ReadOnlyVersion(self, formdescription): def _ReadOnlyVersion(self, formdescription):
"Generate HTML for read-only view of the form" "Generate HTML for read-only view of the form"
R = ['<table class="tf-ro">'] R = ['<table class="tf-ro">']
for (field, descr) in formdescription: for field, descr in formdescription:
R.append(self._ReadOnlyElement(field, descr)) R.append(self._ReadOnlyElement(field, descr))
R.append("</table>") R.append("</table>")
return R return R
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment