From 803e9f274ed3a6a54594435a74e87c47cd0fcb39 Mon Sep 17 00:00:00 2001 From: ailsoncgt Date: Wed, 5 Oct 2016 15:09:02 -0300 Subject: [PATCH] Max date to register user #14 --- core/forms.py | 8 ++++++++ 1 file changed, 8 insertions(+), 0 deletions(-) diff --git a/core/forms.py b/core/forms.py index 780a77d..9e021e1 100644 --- a/core/forms.py +++ b/core/forms.py @@ -1,4 +1,5 @@ from django import forms +from datetime import date from django.utils.translation import ugettext_lazy as _ from users.models import User from pycpfcnpj import cpfcnpj @@ -26,6 +27,13 @@ class RegisterUserForm(forms.ModelForm): raise forms.ValidationError(_('There is already a registered User with this e-mail')) return email + def clean_birth_date(self): + birth_date = self.cleaned_data['birth_date'] + if birth_date >= date.today(): + raise forms.ValidationError(_('Please enter a valid date')) + return birth_date + + def clean_cpf(self): cpf = self.cleaned_data['cpf'] if User.objects.filter(cpf = cpf).exists(): -- libgit2 0.21.2