# Path: breezeminder/forms/validators.py
# class UniqueCardNumber(CardNumber):
#     """ Encrypts a number to check it for uniqueness """
# 
#     def __init__(self, message=None):
#         super(UniqueCardNumber, self).__init__()
#         if message is None:
#             message = 'This card belongs to another user'
#         self.card_message = message
# 
#     def __call__(self, form, field):
#         if not self.active:
#             return
# 
#         super(UniqueCardNumber, self).__call__(form, field)
#         try:
#             check = BreezeCard.objects.get(_number=encrypt(field.data.strip()))
#             if check is not None:
#                 raise ValidationError(self.card_message)
#         except:
#             pass


from wtforms import Form, TextField
from wtforms.validators import required
from breezeminder.forms.validators import UniqueCardNumber



_card_taken_message = 'This number already belongs to another user'


class CreateCardForm(Form):
    cardnumber = TextField('Card Number',
                           validators=[required(),

# Path: breezeminder/forms/validators.py
# class UniqueCardNumber(CardNumber):
#     """ Encrypts a number to check it for uniqueness """
# 
#     def __init__(self, message=None):
#         super(UniqueCardNumber, self).__init__()
#         if message is None:
#             message = 'This card belongs to another user'
#         self.card_message = message
# 
#     def __call__(self, form, field):
#         if not self.active:
#             return
# 
#         super(UniqueCardNumber, self).__call__(form, field)
#         try:
#             check = BreezeCard.objects.get(_number=encrypt(field.data.strip()))
#             if check is not None:
#                 raise ValidationError(self.card_message)
#         except:
#             pass


# Path: breezeminder/forms/card.py
from wtforms import Form, TextField
from wtforms.validators import required
from breezeminder.forms.validators import UniqueCardNumber




_card_taken_message = 'This number already belongs to another user'


class CreateCardForm(Form):
    cardnumber = TextField('Card Number',
                           validators=[required(),

                                       UniqueCardNumber(message=_card_taken_message)])