transaction: change "minValue('0')" to "notZero"
This commit is contained in:
parent
f432ffc70b
commit
38068e1ebb
|
@ -6,6 +6,7 @@ from django.db.models.deletion import SET_NULL
|
|||
from django.db.models.signals import pre_delete
|
||||
from decimal import Decimal
|
||||
|
||||
from validator import validate_notZero
|
||||
|
||||
class TransactionType(models.Model):
|
||||
""" Type for a :class:`Transaction`. States how the money has
|
||||
|
@ -22,7 +23,7 @@ class Transaction(models.Model):
|
|||
user = models.ForeignKey(User)
|
||||
transactionType = models.ForeignKey(TransactionType, verbose_name='Typ')
|
||||
dateTime = models.DateTimeField(auto_now_add=True)
|
||||
amount = models.DecimalField(max_digits=8, decimal_places=2, validators=[MinValueValidator(Decimal("0.01"))])
|
||||
amount = models.DecimalField(max_digits=8, decimal_places=2, validators=[validate_notZero])
|
||||
checked = models.BooleanField(default=False)
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
from django.core.exceptions import ValidationError
|
||||
from decimal import Decimal
|
||||
|
||||
|
||||
def validate_notZero(value):
|
||||
if value == Decimal("0.0") :
|
||||
raise ValidationError(u'%s is not an real number\{0.00}' % value)
|
Loading…
Reference in New Issue