web/views/editcontroller.py
changeset 3163 edfe43ceaa35
parent 3023 7864fee8b4ec
parent 3157 f4b94d03f86f
child 3185 bd0126d17e83
equal deleted inserted replaced
3090:8184bec7414d 3163:edfe43ceaa35
   189         if custom_edit:
   189         if custom_edit:
   190             custom_edit(formparams, value, self.relations)
   190             custom_edit(formparams, value, self.relations)
   191             return
   191             return
   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         if attrtype == 'Boolean':
   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
       
   196         #       form handling will fix that
       
   197         if value and attrtype == 'Int':
       
   198             try:
       
   199                 value = int(value)
       
   200             except ValueError:
       
   201                 raise ValidationError(entity.eid,
       
   202                                       {attr: self.req._("invalid integer value")})
       
   203         elif value and attrtype == 'Float':
       
   204             try:
       
   205                 value = float(value)
       
   206             except ValueError:
       
   207                 raise ValidationError(entity.eid,
       
   208                                       {attr: self.req._("invalid float value")})
       
   209         elif attrtype == 'Boolean':
   195             value = bool(value)
   210             value = bool(value)
   196         elif attrtype == 'Decimal':
   211         elif attrtype == 'Decimal':
   197             value = Decimal(value)
   212             value = Decimal(value)
   198         elif attrtype == 'Bytes':
   213         elif attrtype == 'Bytes':
   199             # if it is a file, transport it using a Binary (StringIO)
   214             # if it is a file, transport it using a Binary (StringIO)