Browse Source

Muda links do botão cancelar

pull/6/head
Eduardo Edson Batista Cordeiro Alves 9 years ago
committed by Luciano Almeida
parent
commit
ca25653105
  1. 2
      sigi/apps/crud/base.py
  2. 55
      sigi/apps/usuarios/forms.py
  3. 4
      sigi/apps/usuarios/layouts.yaml
  4. 8
      sigi/apps/usuarios/urls.py
  5. 43
      sigi/apps/usuarios/views.py
  6. 38
      templates/usuarios/usuario_list.html

2
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

55
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(

4
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

8
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<pk>\d+)$',
HabilitarDetailView.as_view(), name=u'habilitar_detail'),
url(ur'^atendimento/habilitar/(?P<pk>\d+)/edit$',
HabilitarEditView.as_view(), name=u'habilitar_edit'),
url(ur'^atendimento/usuario/(?P<pk>\d+)/mudar_senha$',
MudarSenhaView.as_view(), name=u'mudar_senha'),
url(ur'^usuario/confirmar/(?P<uidb64>[0-9A-Za-z_\-]+)/'

43
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"

38
templates/usuarios/usuario_list.html

@ -1,38 +0,0 @@
{% extends "crud/list.html" %}
{% load i18n %}
{% block buttons %}{% endblock buttons %}
{% block content %}
{% if not rows %}
<p>{{ NO_ENTRIES_MSG }}</p>
{% else %}
<table class="table table-striped table-hover">
<thead>
<tr>
{% for name in headers %}
<th>{{ name }}</th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for value_list in rows %}
<tr>
{% for value, href in value_list %}
<td>
{% if href %}
<a href="../habilitar/{{ value_list|first|last|cut:'/atendimento/usuario/' }}">{{ value }}</a>
{% else %}
{{ value|safe }}
{% endif %}
</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
{% include "paginacao.html" %}
{% endblock content %}
Loading…
Cancel
Save