Commit 8d39cac8e035fc2028489a8aba13c04626728ac2

Authored by juliotoscano
1 parent 0c99ae7f

cpf blank is valid #227

Showing 1 changed file with 5 additions and 5 deletions   Show diff stats
@@ -16,7 +16,7 @@ class RegisterUserForm(forms.ModelForm): @@ -16,7 +16,7 @@ class RegisterUserForm(forms.ModelForm):
16 16
17 def validate_cpf(self, cpf): 17 def validate_cpf(self, cpf):
18 cpf = ''.join(re.findall('\d', str(cpf))) 18 cpf = ''.join(re.findall('\d', str(cpf)))
19 - 19 +
20 if cpfcnpj.validate(cpf): 20 if cpfcnpj.validate(cpf):
21 return True 21 return True
22 return False 22 return False
@@ -38,8 +38,8 @@ class RegisterUserForm(forms.ModelForm): @@ -38,8 +38,8 @@ class RegisterUserForm(forms.ModelForm):
38 cpf = self.cleaned_data['cpf'] 38 cpf = self.cleaned_data['cpf']
39 if User.objects.filter(cpf = cpf).exists(): 39 if User.objects.filter(cpf = cpf).exists():
40 raise forms.ValidationError(_('There is already a registeres User with this CPF')) 40 raise forms.ValidationError(_('There is already a registeres User with this CPF'))
41 - if not self.validate_cpf(cpf):  
42 - raise forms.ValidationError(_('Please enter a valid CPF')) 41 + # if not self.validate_cpf(cpf):
  42 + # raise forms.ValidationError(_('Please enter a valid CPF'))
43 return cpf 43 return cpf
44 44
45 def clean_password(self): 45 def clean_password(self):
@@ -68,12 +68,12 @@ class RegisterUserForm(forms.ModelForm): @@ -68,12 +68,12 @@ class RegisterUserForm(forms.ModelForm):
68 def save(self, commit=True): 68 def save(self, commit=True):
69 super(RegisterUserForm, self).save(commit=False) 69 super(RegisterUserForm, self).save(commit=False)
70 self.instance.set_password(self.cleaned_data['password']) 70 self.instance.set_password(self.cleaned_data['password'])
71 - 71 +
72 self.instance.save() 72 self.instance.save()
73 return self.instance 73 return self.instance
74 74
75 class Meta: 75 class Meta:
76 model = User 76 model = User
77 # exclude = ['is_staff', 'is_active'] 77 # exclude = ['is_staff', 'is_active']
78 - fields = ['username', 'name', 'email', 'city', 'state', 'gender', 'cpf', 'birth_date', 'phone', 'image', 'titration', 78 + fields = ['username', 'name', 'email', 'city', 'state', 'gender', 'cpf', 'birth_date', 'phone', 'image', 'titration',
79 'year_titration', 'institution', 'curriculum',] 79 'year_titration', 'institution', 'curriculum',]
80 \ No newline at end of file 80 \ No newline at end of file