3 from tw.forms import validators
5 from bluechips import model
6 from bluechips.model import meta
8 from decimal import Decimal
10 class UserSelect(forms.SingleSelectField):
13 for u in meta.Session.query(model.User):
17 validator = validators.Wrapper(
18 to_python=(lambda x: meta.Session.query(model.User).get(int(x))),
19 from_python=(lambda x: str(x.id)))
21 def _is_option_selected(self, option_value, value):
22 return option_value == value.id
24 class AmountField(forms.TextField):
26 validator = validators.All(
30 validators.Regex(r'^[0-9]*(\.[0-9]{2})?$', not_empty=True))
32 __all__ = ['UserSelect', 'AmountField']