|
@ -211,21 +211,34 @@ class UsuarioForm(ModelForm): |
|
|
u.save() |
|
|
u.save() |
|
|
usuario.user = u |
|
|
usuario.user = u |
|
|
usuario.save() |
|
|
usuario.save() |
|
|
|
|
|
return usuario |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class UsuarioEditForm(UsuarioForm): |
|
|
class UsuarioEditForm(UsuarioForm): |
|
|
|
|
|
captcha = CaptchaField(required=False) |
|
|
|
|
|
|
|
|
|
|
|
casa_legislativa = forms.ModelChoiceField( |
|
|
|
|
|
queryset=CasaLegislativa.objects.all(), |
|
|
|
|
|
widget=Select2(), |
|
|
|
|
|
required=False |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
class Meta(object): |
|
|
class Meta(object): |
|
|
model = Usuario |
|
|
model = Usuario |
|
|
fields = [u'username', u'email', u'nome_completo', u'vinculo', |
|
|
fields = [u'username', u'email', u'nome_completo', u'vinculo', |
|
|
u'email_confirm', u'captcha', u'cpf', u'rg', |
|
|
u'email_confirm', u'cpf', u'rg', u'cargo'] |
|
|
u'cargo', u'casa_legislativa'] |
|
|
exclude = [u'captcha', u'casa_legislativa'] |
|
|
|
|
|
|
|
|
widgets = {u'username': forms.TextInput( |
|
|
widgets = {u'username': forms.TextInput( |
|
|
|
|
|
attrs={u'readonly': u'readonly'}), |
|
|
|
|
|
u'nome_completo': forms.TextInput( |
|
|
|
|
|
attrs={u'readonly': u'readonly'}), |
|
|
|
|
|
u'cpf': forms.TextInput( |
|
|
|
|
|
attrs={u'readonly': u'readonly'}), |
|
|
|
|
|
u'rg': forms.TextInput( |
|
|
attrs={u'readonly': u'readonly'}), |
|
|
attrs={u'readonly': u'readonly'}), |
|
|
u'email': forms.TextInput( |
|
|
u'email': forms.TextInput( |
|
|
attrs={u'style': u'text-transform:lowercase;'} |
|
|
attrs={u'style': u'text-transform:lowercase;'}), } |
|
|
), |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs): |
|
|
def __init__(self, *args, **kwargs): |
|
|
super(UsuarioEditForm, self).__init__(*args, **kwargs) |
|
|
super(UsuarioEditForm, self).__init__(*args, **kwargs) |
|
@ -242,7 +255,6 @@ class UsuarioEditForm(UsuarioForm): |
|
|
user__username=self.cleaned_data[u'username']).exists() |
|
|
user__username=self.cleaned_data[u'username']).exists() |
|
|
|
|
|
|
|
|
def clean(self): |
|
|
def clean(self): |
|
|
|
|
|
|
|
|
if (u'email' not in self.cleaned_data or |
|
|
if (u'email' not in self.cleaned_data or |
|
|
u'email_confirm' not in self.cleaned_data): |
|
|
u'email_confirm' not in self.cleaned_data): |
|
|
raise ValidationError(_(u'Favor informar endereços de email')) |
|
|
raise ValidationError(_(u'Favor informar endereços de email')) |
|
@ -263,7 +275,6 @@ class UsuarioEditForm(UsuarioForm): |
|
|
|
|
|
|
|
|
@transaction.atomic |
|
|
@transaction.atomic |
|
|
def save(self, commit=False): |
|
|
def save(self, commit=False): |
|
|
|
|
|
|
|
|
usuario = super(UsuarioForm, self).save(commit) |
|
|
usuario = super(UsuarioForm, self).save(commit) |
|
|
|
|
|
|
|
|
# Primeiro telefone |
|
|
# Primeiro telefone |
|
@ -415,13 +426,10 @@ class RecuperarSenhaEmailForm(PasswordResetForm): |
|
|
Fieldset(_(u'Recuperar Senha'), |
|
|
Fieldset(_(u'Recuperar Senha'), |
|
|
row1, |
|
|
row1, |
|
|
form_actions( |
|
|
form_actions( |
|
|
more=[ |
|
|
more=[Submit(u'Cancelar', |
|
|
Submit( |
|
|
|
|
|
u'Cancelar', |
|
|
|
|
|
u'Cancelar', |
|
|
u'Cancelar', |
|
|
style=u'background-color:black; color:white;')]) |
|
|
style=u'background-color:black;' |
|
|
) |
|
|
'color:white;')]))) |
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
def clean(self): |
|
|
def clean(self): |
|
|
email_existente_usuario = Usuario.objects.filter( |
|
|
email_existente_usuario = Usuario.objects.filter( |
|
@ -448,10 +456,7 @@ class RecuperacaoMudarSenhaForm(SetPasswordForm): |
|
|
Fieldset(_(u''), |
|
|
Fieldset(_(u''), |
|
|
row1, |
|
|
row1, |
|
|
form_actions( |
|
|
form_actions( |
|
|
more=[ |
|
|
more=[Submit(u'Cancelar', |
|
|
Submit( |
|
|
|
|
|
u'Cancelar', |
|
|
|
|
|
u'Cancelar', |
|
|
u'Cancelar', |
|
|
style=u'background-color:black; color:white;')]) |
|
|
style=u'background-color:black;' |
|
|
) |
|
|
'color:white;')]))) |
|
|
) |
|
|
|
|
|