Author: tmckay
Date: 2011-03-21 13:01:20 +0000 (Mon, 21 Mar 2011)
New Revision: 4645
Modified:
trunk/cumin/python/cumin/grid/limit.py
trunk/wooly/python/wooly/forms.py
Log:
Change Max Allowance field to allow float in addition to integer.
BZ679672
Modified: trunk/cumin/python/cumin/grid/limit.py
===================================================================
--- trunk/cumin/python/cumin/grid/limit.py 2011-03-21 12:15:05 UTC (rev 4644)
+++ trunk/cumin/python/cumin/grid/limit.py 2011-03-21 13:01:20 UTC (rev 4645)
@@ -9,7 +9,7 @@
from cumin.qmfadapter import ObjectQmfAdapter
from cumin.widgets import CuminView
-from wooly.forms import StringField, StringInput, IntegerField
+from wooly.forms import StringField, StringInput, IntegerField, RealField
from wooly.util import StringCatalog
from wooly.widgets import TabbedModeSet
@@ -204,7 +204,7 @@
# used to override html and css
pass
- class LimitMax(IntegerField):
+ class LimitMax(RealField):
def render_title(self, session):
return "Max Allowance"
Modified: trunk/wooly/python/wooly/forms.py
===================================================================
--- trunk/wooly/python/wooly/forms.py 2011-03-21 12:15:05 UTC (rev 4644)
+++ trunk/wooly/python/wooly/forms.py 2011-03-21 13:01:20 UTC (rev 4645)
@@ -197,6 +197,15 @@
self.size = 15
+class FloatInput(ScalarInput):
+ def __init__(self, app, name):
+ super(FloatInput, self).__init__(app, name, None)
+
+ self.param = FloatParameter(app, "param")
+ self.add_parameter(self.param)
+
+ self.size = 15
+
class CheckboxInput(FormInput):
def __init__(self, app, name, param=None):
super(CheckboxInput, self).__init__(app, name, param)
@@ -471,6 +480,26 @@
message = "The '%s' field must be an integer" % title
self.form.errors.add(session, FormError(message))
+class RealField(ScalarField):
+ def __init__(self, app, name):
+ super(RealField, self).__init__(app, name, None)
+
+ self.input = FloatInput(app, "input")
+ self.add_child(self.input)
+
+ def validate(self, session):
+ super(RealField, self).validate(session)
+
+ value = self.get(session)
+
+ if value:
+ try:
+ value = float(value)
+ except:
+ title = self.render_title(session)
+ message = "The '%s' field must be an integer or float"
% title
+ self.form.errors.add(session, FormError(message))
+
# XXX make this use a RadioInputSet instead?
class RadioField(FormField):
def __init__(self, app, name, param):
Show replies by date