Commit 8061c328 authored by Hugo LEVY-FALK's avatar Hugo LEVY-FALK

Un fichier validators pour les validator.

parent c819cc89
......@@ -52,6 +52,7 @@ from re2o.field_permissions import FieldPermissionModelMixin
from re2o.mixins import AclMixin, RevMixin
from cotisations.utils import find_payment_method
from cotisations.validators import check_no_balance
# TODO : change facture to invoice
......@@ -605,18 +606,6 @@ class Banque(RevMixin, AclMixin, models.Model):
return self.name
def check_no_balance():
"""This functions checks that no Paiement with is_balance=True exists
Raises:
ValidationError: if such a Paiement exists.
"""
p = Paiement.objects.filter(is_balance=True)
if len(p)>0:
raise ValidationError(
_("There are already payment method(s) for user balance")
)
# TODO : change Paiement to Payment
class Paiement(RevMixin, AclMixin, models.Model):
"""
......
from django.forms import ValidationError
from django.utils.translation import ugettext as _
def check_no_balance(is_balance):
"""This functions checks that no Paiement with is_balance=True exists
Args:
is_balance: True if the model is balance.
Raises:
ValidationError: if such a Paiement exists.
"""
from .models import Paiement
if not is_balance:
return
p = Paiement.objects.filter(is_balance=True)
if len(p) > 0:
raise ValidationError(
_("There are already payment method(s) for user balance")
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment