8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-17 20:43:46 +00:00
re2o/cotisations/validators.py

23 lines
586 B
Python
Raw Normal View History

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(
2018-06-23 17:54:20 +00:00
_("There is already a payment method for user balance.")
)
2018-06-23 17:54:20 +00:00