From 2ca5d22df820458b8c25d2971ea8ca3cadabbb09 Mon Sep 17 00:00:00 2001 From: Jan Max Meyer Date: Mon, 15 Apr 2019 16:10:42 +0200 Subject: [PATCH] Allow empty date setting to dateBone Setting a date back to empty is not possible using fromClient right now: Empty string is converted to None, and None is not allowed by super-call to baseBone.isInvalid() as valid value. So this might fix the problem and integrates with [#32](https://github.com/viur-framework/vi/pull/32) in vi. --- bones/dateBone.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bones/dateBone.py b/bones/dateBone.py index 36918b4..1485d9e 100644 --- a/bones/dateBone.py +++ b/bones/dateBone.py @@ -99,7 +99,7 @@ def fromClient( self,valuesCache, name, data ): """ rawValue = data.get(name, None) if not rawValue: - value = None + value = rawValue elif unicode(rawValue).replace("-", "", 1).replace(".","",1).isdigit(): if int(rawValue) < -1*(2**30) or int(rawValue)>(2**31)-2: value = False # its invalid @@ -158,7 +158,7 @@ def fromClient( self,valuesCache, name, data ): else: err = self.isInvalid(value) if not err: - valuesCache[name] = value + valuesCache[name] = value if value else None if value is None: return "No value entered" return err