]> asedeno.scripts.mit.edu Git - bluechips.git/blobdiff - bluechips/model/types.py
Convert the README to rST, since that's what distutils wants.
[bluechips.git] / bluechips / model / types.py
index fdd3b8bd4c6ce1c622960c0df02827a4965427c3..8cea5e8b107d781fe716e26f572f4eda3694bdc5 100644 (file)
@@ -38,7 +38,8 @@ locale.localeconv = localeconv
 class CurrencyValidator(validators.FancyValidator):
     "A validator to convert to Currency objects."
     messages = {'amount': "Please enter a valid currency amount",
-                'precision': "Only two digits after the decimal, please"}
+                'precision': "Only two digits after the decimal, please",
+                'nonzero': "Please enter a non-zero amount"}
 
     def _to_python(self, value, state):
         try:
@@ -48,7 +49,10 @@ class CurrencyValidator(validators.FancyValidator):
                           value, state)
         else:
             ret = dec.quantize(Decimal('1.00'))
-            if ret != dec:
+            if ret == 0:
+                raise Invalid(self.message('nonzero', state),
+                              value, state)
+            elif ret != dec:
                 raise Invalid(self.message('precision', state),
                               value, state)
             else:
@@ -119,12 +123,6 @@ class Currency(object):
         """
         return self.__mul__(other)
     
-    def __str_no_dollar__(self):
-        """
-        Get to the formatted string without the dollar sign
-        """
-        return str(self).replace('$', '')
-    
     def __repr__(self):
         return '%s("%s")' % (self.__class__.__name__, str(self))
     def __str__(self):