Commit 803e9f274ed3a6a54594435a74e87c47cd0fcb39

Authored by ailsoncgt
1 parent 5b804ca4

Max date to register user #14

Showing 1 changed file with 8 additions and 0 deletions   Show diff stats
core/forms.py
1 1 from django import forms
  2 +from datetime import date
2 3 from django.utils.translation import ugettext_lazy as _
3 4 from users.models import User
4 5 from pycpfcnpj import cpfcnpj
... ... @@ -26,6 +27,13 @@ class RegisterUserForm(forms.ModelForm):
26 27 raise forms.ValidationError(_('There is already a registered User with this e-mail'))
27 28 return email
28 29  
  30 + def clean_birth_date(self):
  31 + birth_date = self.cleaned_data['birth_date']
  32 + if birth_date >= date.today():
  33 + raise forms.ValidationError(_('Please enter a valid date'))
  34 + return birth_date
  35 +
  36 +
29 37 def clean_cpf(self):
30 38 cpf = self.cleaned_data['cpf']
31 39 if User.objects.filter(cpf = cpf).exists():
... ...