From ca25653105997af7c8c2e96c5b7ee851b35e5d83 Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Thu, 30 Jun 2016 16:36:52 -0300 Subject: [PATCH] =?UTF-8?q?Muda=20links=20do=20bot=C3=A3o=20cancelar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sigi/apps/crud/base.py | 2 +- sigi/apps/usuarios/forms.py | 55 +++++----------------------- sigi/apps/usuarios/layouts.yaml | 4 -- sigi/apps/usuarios/urls.py | 8 +--- sigi/apps/usuarios/views.py | 43 +--------------------- templates/usuarios/usuario_list.html | 38 ------------------- 6 files changed, 12 insertions(+), 138 deletions(-) delete mode 100644 templates/usuarios/usuario_list.html diff --git a/sigi/apps/crud/base.py b/sigi/apps/crud/base.py index b1a9ad3..d15b45b 100644 --- a/sigi/apps/crud/base.py +++ b/sigi/apps/crud/base.py @@ -131,7 +131,7 @@ class CrudCreateView(FormMessagesMixin, CreateView): @property def cancel_url(self): - return self.list_url + return '/atendimento' def get_success_url(self): return self.detail_url diff --git a/sigi/apps/usuarios/forms.py b/sigi/apps/usuarios/forms.py index e204d5f..446fd74 100644 --- a/sigi/apps/usuarios/forms.py +++ b/sigi/apps/usuarios/forms.py @@ -5,7 +5,7 @@ from datetime import datetime from captcha.fields import CaptchaField from crispy_forms.helper import FormHelper -from crispy_forms.layout import HTML, Fieldset, Layout, Submit +from crispy_forms.layout import HTML, Button, Fieldset, Layout, Submit from django import forms from django.contrib.auth.forms import (AuthenticationForm, PasswordResetForm, SetPasswordForm) @@ -386,42 +386,6 @@ class UsuarioEditForm(UsuarioForm): return usuario -class HabilitarEditForm(ModelForm): - habilitado = forms.ChoiceField( - widget=forms.Select(), - required=True, - choices=YES_NO_CHOICES) - - class Meta(object): - model = Usuario - fields = [u'cpf', u'nome_completo', u'email', u'habilitado'] - widgets = { - u'cpf': forms.TextInput(attrs={u'readonly': u'readonly'}), - u'nome_completo': forms.TextInput(attrs={u'readonly': u'readonly'} - ), - u'email': forms.TextInput(attrs={u'readonly': u'readonly'}) - } - - def __init__(self, *args, **kwargs): - super(HabilitarEditForm, self).__init__(*args, **kwargs) - row1 = sigi.apps.crispy_layout_mixin.to_row( - [(u'nome_completo', 4), - (u'cpf', 4), - (u'email', 4)]) - row2 = sigi.apps.crispy_layout_mixin.to_row([(u'habilitado', 12)]) - self.helper = FormHelper() - self.helper.layout = Layout( - Fieldset( - _(u'Editar usuário'), row1, row2, form_actions( - more=[ - Submit( - u'Cancelar', - u'Cancelar', - style=u'background-color:black; color:white;')]) - ) - ) - - class MudarSenhaForm(ModelForm): password = forms.CharField( @@ -434,8 +398,6 @@ class MudarSenhaForm(ModelForm): label=_(u'Confirmar Nova Senha'), widget=forms.PasswordInput()) - captcha = CaptchaField() - def valida_igualdade(self, texto1, texto2, msg): if texto1 != texto2: raise ValidationError(msg) @@ -460,24 +422,24 @@ class MudarSenhaForm(ModelForm): class Meta(object): model = Usuario - fields = [u'password', u'password_confirm', u'captcha'] + fields = [u'password', u'password_confirm'] def __init__(self, *args, **kwargs): super(MudarSenhaForm, self).__init__(*args, **kwargs) row1 = sigi.apps.crispy_layout_mixin.to_row( [(u'password', 6), (u'password_confirm', 6)]) - row2 = sigi.apps.crispy_layout_mixin.to_row([(u'captcha', 12)]) self.helper = FormHelper() self.helper.layout = Layout( Fieldset( - _(u'Mudar Senha'), row1, row2, + _(u'Mudar Senha'), row1, form_actions( more=[ - Submit( + Button( u'Cancelar', u'Cancelar', - style=u'background-color:black; color:white;')]) + style=u'background-color:black; color:white;', + onclick="window.history.back()")]) ) ) @@ -493,10 +455,11 @@ class RecuperarSenhaEmailForm(PasswordResetForm): Fieldset(_(u'Recuperar Senha'), row1, form_actions( - more=[Submit(u'Cancelar', + more=[Button(u'Cancelar', u'Cancelar', style=u'background-color:black;' - 'color:white;')]))) + 'color:white;', + onclick="window.history.back()")]))) def clean(self): email_existente_usuario = Usuario.objects.filter( diff --git a/sigi/apps/usuarios/layouts.yaml b/sigi/apps/usuarios/layouts.yaml index 227859b..20ea31a 100644 --- a/sigi/apps/usuarios/layouts.yaml +++ b/sigi/apps/usuarios/layouts.yaml @@ -7,10 +7,6 @@ CasaLegislativa: - telefone - endereco_web -Subsecretaria: - Subsecretaria: - - nome:8 sigla - Usuario: Dados do Usuário: - username nome_completo:9 diff --git a/sigi/apps/usuarios/urls.py b/sigi/apps/usuarios/urls.py index ca235f4..a14fd60 100644 --- a/sigi/apps/usuarios/urls.py +++ b/sigi/apps/usuarios/urls.py @@ -10,8 +10,7 @@ from django.views.generic.base import TemplateView from sigi.apps.usuarios.forms import (LoginForm, RecuperacaoMudarSenhaForm, RecuperarSenhaEmailForm) from sigi.apps.usuarios.views import (ConfirmarEmailView, ConveniadoListView, - ConveniadoView, HabilitarDetailView, - HabilitarEditView, MudarSenhaView, + ConveniadoView, MudarSenhaView, ResponsavelListView, ResponsavelView, UsuarioCrud) @@ -55,11 +54,6 @@ urlpatterns = recuperar_email + [ url(ur'^atendimento/logout/$', logout, {u'next_page': u'/atendimento'}, name=u'logout'), url(ur'^atendimento/usuario/', include(UsuarioCrud.get_urls())), - - url(ur'^atendimento/habilitar/(?P\d+)$', - HabilitarDetailView.as_view(), name=u'habilitar_detail'), - url(ur'^atendimento/habilitar/(?P\d+)/edit$', - HabilitarEditView.as_view(), name=u'habilitar_edit'), url(ur'^atendimento/usuario/(?P\d+)/mudar_senha$', MudarSenhaView.as_view(), name=u'mudar_senha'), url(ur'^usuario/confirmar/(?P[0-9A-Za-z_\-]+)/' diff --git a/sigi/apps/usuarios/views.py b/sigi/apps/usuarios/views.py index 2d67804..bbd9032 100644 --- a/sigi/apps/usuarios/views.py +++ b/sigi/apps/usuarios/views.py @@ -167,7 +167,7 @@ class UsuarioCrud(Crud): url_base = full_url[0][:full_url[0].find(u'atendimento') - 1], mensagem = (u"Este e-mail foi utilizado para fazer cadastro no " + u"Sistema de Atendimento ao Usuário do Interlegis.\n" + - u"Clique no link abaixo para confirmar o cadastro:\n\n" + + u"Clique no link abaixo para confirmar o cadastro:\n" + url_base[0] + reverse(u'usuarios:confirmar_email', kwargs=kwargs) + u"\n\nCaso você não tenha feito este cadastro, " + @@ -223,47 +223,6 @@ class UsuarioCrud(Crud): def layout_key(self): return u'UsuarioDetail' - class BaseMixin(CrudBaseMixin): - list_field_names = [u'username', u'nome_completo', - u'data_criacao', u'habilitado', - u'data_ultima_atualizacao'] - - -class HabilitarDetailView(CrudDetailView): - template_name = u"usuarios/habilitar_detail.html" - - def get(self, request, *args, **kwargs): - context = {} - context[u'pk'] = self.kwargs[u'pk'] - context[u'usuario'] = Usuario.objects.get(pk=self.kwargs[u'pk']) - return self.render_to_response(context) - - -class HabilitarEditView(FormView): - template_name = u"crud/form.html" - - def get(self, request, *args, **kwargs): - context = {} - - usuario = Usuario.objects.get(pk=self.kwargs[u'pk']) - form = HabilitarEditForm(instance=usuario) - - context[u'pk'] = self.kwargs[u'pk'] - context[u'form'] = form - return self.render_to_response(context) - - def post(self, request, *args, **kwargs): - form = HabilitarEditForm(request.POST) - usuario = Usuario.objects.get(pk=self.kwargs[u'pk']) - usuario.habilitado = str2bool(form.data[u'habilitado']) - usuario.data_ultima_atualizacao = timezone.now() - - usuario.save() - return self.form_valid(form) - - def get_success_url(self): - return reverse(u'usuarios:usuario_list') - class MudarSenhaView(FormValidMessageMixin, FormView): template_name = u"crud/form.html" diff --git a/templates/usuarios/usuario_list.html b/templates/usuarios/usuario_list.html deleted file mode 100644 index e596179..0000000 --- a/templates/usuarios/usuario_list.html +++ /dev/null @@ -1,38 +0,0 @@ -{% extends "crud/list.html" %} -{% load i18n %} - -{% block buttons %}{% endblock buttons %} - -{% block content %} - - {% if not rows %} -

{{ NO_ENTRIES_MSG }}

- {% else %} - - - - {% for name in headers %} - - {% endfor %} - - - - {% for value_list in rows %} - - {% for value, href in value_list %} - - {% endfor %} - - {% endfor %} - -
{{ name }}
- {% if href %} - {{ value }} - {% else %} - {{ value|safe }} - {% endif %} -
- {% endif %} - - {% include "paginacao.html" %} -{% endblock content %}