From 15bb053ac073753a34879480aa814a963d2444dd Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Tue, 28 Jun 2016 17:07:05 -0300 Subject: [PATCH] =?UTF-8?q?#39=20Remove=20captcha=20e=20torna=20campos=20r?= =?UTF-8?q?eadonly=20na=20edi=C3=A7=C3=A3o=20do=20perfil?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sigi/apps/usuarios/forms.py | 51 ++++++++++--------- sigi/apps/usuarios/layouts.yaml | 4 +- .../0006_remove_usuario_search_text.py | 19 +++++++ sigi/apps/usuarios/models.py | 2 - 4 files changed, 48 insertions(+), 28 deletions(-) create mode 100644 sigi/apps/usuarios/migrations/0006_remove_usuario_search_text.py diff --git a/sigi/apps/usuarios/forms.py b/sigi/apps/usuarios/forms.py index 0261cb5..47d528d 100644 --- a/sigi/apps/usuarios/forms.py +++ b/sigi/apps/usuarios/forms.py @@ -101,7 +101,7 @@ class UsuarioForm(ModelForm): u'captcha', u'cpf', u'rg', u'cargo', u'casa_legislativa'] widgets = {u'email': forms.TextInput( - attrs={u'style': u'text-transform:lowercase;'}), } + attrs={u'style': u'text-transform:lowercase;'}), } def __init__(self, *args, **kwargs): super(UsuarioForm, self).__init__(*args, **kwargs) @@ -211,21 +211,34 @@ class UsuarioForm(ModelForm): u.save() usuario.user = u usuario.save() + return usuario class UsuarioEditForm(UsuarioForm): + captcha = CaptchaField(required=False) + + casa_legislativa = forms.ModelChoiceField( + queryset=CasaLegislativa.objects.all(), + widget=Select2(), + required=False + ) class Meta(object): model = Usuario fields = [u'username', u'email', u'nome_completo', u'vinculo', - u'email_confirm', u'captcha', u'cpf', u'rg', - u'cargo', u'casa_legislativa'] + u'email_confirm', u'cpf', u'rg', u'cargo'] + exclude = [u'captcha', u'casa_legislativa'] + widgets = {u'username': forms.TextInput( - attrs={u'readonly': u'readonly'}), + 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'}), u'email': forms.TextInput( - attrs={u'style': u'text-transform:lowercase;'} - ), - } + attrs={u'style': u'text-transform:lowercase;'}), } def __init__(self, *args, **kwargs): super(UsuarioEditForm, self).__init__(*args, **kwargs) @@ -242,7 +255,6 @@ class UsuarioEditForm(UsuarioForm): user__username=self.cleaned_data[u'username']).exists() def clean(self): - if (u'email' not in self.cleaned_data or u'email_confirm' not in self.cleaned_data): raise ValidationError(_(u'Favor informar endereços de email')) @@ -263,7 +275,6 @@ class UsuarioEditForm(UsuarioForm): @transaction.atomic def save(self, commit=False): - usuario = super(UsuarioForm, self).save(commit) # Primeiro telefone @@ -415,13 +426,10 @@ class RecuperarSenhaEmailForm(PasswordResetForm): Fieldset(_(u'Recuperar Senha'), row1, form_actions( - more=[ - Submit( - u'Cancelar', - u'Cancelar', - style=u'background-color:black; color:white;')]) - ) - ) + more=[Submit(u'Cancelar', + u'Cancelar', + style=u'background-color:black;' + 'color:white;')]))) def clean(self): email_existente_usuario = Usuario.objects.filter( @@ -448,10 +456,7 @@ class RecuperacaoMudarSenhaForm(SetPasswordForm): Fieldset(_(u''), row1, form_actions( - more=[ - Submit( - u'Cancelar', - u'Cancelar', - style=u'background-color:black; color:white;')]) - ) - ) + more=[Submit(u'Cancelar', + u'Cancelar', + style=u'background-color:black;' + 'color:white;')]))) diff --git a/sigi/apps/usuarios/layouts.yaml b/sigi/apps/usuarios/layouts.yaml index 92b8e7d..227859b 100644 --- a/sigi/apps/usuarios/layouts.yaml +++ b/sigi/apps/usuarios/layouts.yaml @@ -29,14 +29,12 @@ UsuarioEdit: Usuário: - username nome_completo:9 - email email_confirm - - cpf rg casa_legislativa + - cpf rg - cargo vinculo Primeiro Telefone: - primeiro_tipo primeiro_ddd:2 primeiro_numero:6 primeiro_principal Segundo Telefone: - segundo_tipo segundo_ddd:2 segundo_numero:6 segundo_principal - Prove que você é um humano: - - captcha UsuarioDetail: Perfil: diff --git a/sigi/apps/usuarios/migrations/0006_remove_usuario_search_text.py b/sigi/apps/usuarios/migrations/0006_remove_usuario_search_text.py new file mode 100644 index 0000000..611d3d6 --- /dev/null +++ b/sigi/apps/usuarios/migrations/0006_remove_usuario_search_text.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.6 on 2016-06-28 15:04 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('usuarios', '0005_auto_20160624_0853'), + ] + + operations = [ + migrations.RemoveField( + model_name='usuario', + name='search_text', + ), + ] diff --git a/sigi/apps/usuarios/models.py b/sigi/apps/usuarios/models.py index 639a5de..024324e 100644 --- a/sigi/apps/usuarios/models.py +++ b/sigi/apps/usuarios/models.py @@ -120,8 +120,6 @@ class Usuario(models.Model): 'casas.CasaLegislativa', verbose_name=_(u'Casa Legislativa') ) - # campo de busca em caixa baixa e sem acentos - search_text = SearchField(field_names=['casa_legislativa']) class Meta(object): verbose_name = _(u'Usuário')