[web] Handle unspecified 'date' or 'time' in JQueryDateTimePicker.process_field_data() 3.24
authorDenis Laxalde <denis.laxalde@logilab.fr>
Thu, 26 Jan 2017 16:33:15 +0100
branch3.24
changeset 11921 a03376213747
parent 11917 c38e13988c10
child 11922 5f886dc718ab
[web] Handle unspecified 'date' or 'time' in JQueryDateTimePicker.process_field_data() dict.get() may return None, which has no attribute strip.
cubicweb/web/formwidgets.py
--- a/cubicweb/web/formwidgets.py	Fri Jan 20 15:16:18 2017 +0100
+++ b/cubicweb/web/formwidgets.py	Thu Jan 26 16:33:15 2017 +0100
@@ -801,8 +801,12 @@
 
     def process_field_data(self, form, field):
         req = form._cw
-        datestr = req.form.get(field.input_name(form, 'date')).strip() or None
-        timestr = req.form.get(field.input_name(form, 'time')).strip() or None
+        datestr = req.form.get(field.input_name(form, 'date'))
+        if datestr:
+            datestr = datestr.strip() or None
+        timestr = req.form.get(field.input_name(form, 'time'))
+        if timestr:
+            timestr = timestr.strip() or None
         if datestr is None:
             return None
         try: