web/views/editcontroller.py
branchstable
changeset 3157 f4b94d03f86f
parent 3092 c153b1ae9875
child 3163 edfe43ceaa35
child 3164 b025592ff478
equal deleted inserted replaced
3144:a5deac822a13 3157:f4b94d03f86f
   192         attrtype = rschema.objects(entity.e_schema)[0].type
   192         attrtype = rschema.objects(entity.e_schema)[0].type
   193         # on checkbox or selection, the field may not be in params
   193         # on checkbox or selection, the field may not be in params
   194         # NOTE: raising ValidationError here is not a good solution because
   194         # NOTE: raising ValidationError here is not a good solution because
   195         #       we can't gather all errors at once. Hopefully, the new 3.6.x
   195         #       we can't gather all errors at once. Hopefully, the new 3.6.x
   196         #       form handling will fix that
   196         #       form handling will fix that
   197         if attrtype == 'Int':
   197         if value and attrtype == 'Int':
   198             try:
   198             try:
   199                 value = int(value)
   199                 value = int(value)
   200             except ValueError:
   200             except ValueError:
   201                 raise ValidationError(entity.eid,
   201                 raise ValidationError(entity.eid,
   202                                       {attr: self.req._("invalid integer value")})
   202                                       {attr: self.req._("invalid integer value")})
   203         elif attrtype == 'Float':
   203         elif value and attrtype == 'Float':
   204             try:
   204             try:
   205                 value = float(value)
   205                 value = float(value)
   206             except ValueError:
   206             except ValueError:
   207                 raise ValidationError(entity.eid,
   207                 raise ValidationError(entity.eid,
   208                                       {attr: self.req._("invalid float value")})
   208                                       {attr: self.req._("invalid float value")})