def clean(self): cleaned_data = self.cleaned_data if cleaned_data.get('number'): if match_password(cleaned_data.get('number')): raise forms.ValidationError(u'Wrong PIN. Should be 4 digits.') else: raise forms.ValidationError(u'PIN is empty. Enter correct PIN') return cleaned_data
def create_user(self, number, password, is_active=True, is_admin=False): # Creates Card and Card Account if match_number(number): raise ValueError(u"Wrong Card Number! Must be 16 digits starting from 1.") if match_password(password): raise ValueError(u"Wrong Password! Must be 4 digits.") card = self.model( number=number, is_active=is_active, is_admin=is_admin ) card.set_password(password) card.save(using=self._db) return card