update LdtDurationField to correctly test if the value is an integer, and send custom message error if it's not
authorrougeronj
Mon, 14 Jan 2013 14:58:03 +0100
changeset 1062 14c98d369c5a
parent 1061 92e3a410e192
child 1063 14f0561de20e
update LdtDurationField to correctly test if the value is an integer, and send custom message error if it's not
src/ldt/ldt/forms/fields.py
--- a/src/ldt/ldt/forms/fields.py	Mon Jan 14 14:48:46 2013 +0100
+++ b/src/ldt/ldt/forms/fields.py	Mon Jan 14 14:58:03 2013 +0100
@@ -5,7 +5,6 @@
 from django import forms
 from django.utils.translation import ugettext_lazy as _
 from django.core.exceptions import ValidationError
-from django.core.validators import validate_integer
 import logging
 import time
 import math
@@ -38,12 +37,16 @@
                 dur = dur*1000
                 break
             except:
-                pass
+                logging.debug("trying next format")
+        logging.debug(str(dur))
         return dur
     
     def validate(self, value):
         if value==None or value=="":
             raise ValidationError(self.default_error_messages['required'])
         else:
-            validate_integer(self.default_error_messages['invalid'])
+            try:
+                int(value)
+            except (ValueError, TypeError):
+                raise ValidationError(self.default_error_messages['invalid'])
             
\ No newline at end of file