Browse Source

transaction: change "minValue('0')" to "notZero"

master
Sebastian Lohff 11 years ago
parent
commit
38068e1ebb
  1. 3
      k4ever/transaction/models.py
  2. 7
      k4ever/transaction/validator.py

3
k4ever/transaction/models.py

@ -6,6 +6,7 @@ from django.db.models.deletion import SET_NULL @@ -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): @@ -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)

7
k4ever/transaction/validator.py

@ -0,0 +1,7 @@ @@ -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…
Cancel
Save