+class SubscribeForm(forms.Form):
+ full_name = forms.CharField(label=u'Nome completo', max_length=255)
+ email = forms.EmailField()
+ username = forms.CharField(max_length=255)
+ password = forms.CharField(label=u'Senha',
+ max_length=255,
+ widget=forms.PasswordInput)
+ confirm_password = forms.CharField(label=u'Confirmar senha',
+ max_length=255,
+ widget=forms.PasswordInput)
+
+ def clean_username(self):
+ data = self.cleaned_data['username']
+ if User.objects.filter(username=data):
+ raise forms.ValidationError(u'O usuário "%s" já existe' % data)
+ return data
+
+ def clean_confirm_password(self):
+ passwd = self.cleaned_data['password']
+ conf_passwd = self.cleaned_data['confirm_password']
+ if passwd != conf_passwd:
+ raise forms.ValidationError(u'A confirmação difere da senha')
+ return conf_passwd
+