From 9f655546c3e9ab76e34bfd2502540011582ce182 Mon Sep 17 00:00:00 2001 From: Gilson Filho Date: Tue, 29 Nov 2011 20:41:59 +0000 Subject: [PATCH] =?UTF-8?q?Implementando=20a=20autentica=C3=A7=C3=A3o=20do?= =?UTF-8?q?=20usu=C3=A1rio=20para=20acessar=20o=20diagn=C3=B3stico,=20como?= =?UTF-8?q?=20tamb=C3=A9m=20filtrar=20os=20registros=20a=20partir=20do=20s?= =?UTF-8?q?tatus=20e=20se=20as=20mesmas=20s=C3=A3o=20do=20servidor=20logad?= =?UTF-8?q?o.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sigi/apps/diagnosticos/admin.py | 2 +- sigi/apps/diagnosticos/urls.py | 10 +++++ sigi/apps/diagnosticos/views.py | 11 +++-- sigi/apps/servidores/admin.py | 1 + sigi/settings.py | 3 ++ .../diagnosticos/diagnosticos_list.html | 4 +- .../diagnosticos/diagnosticos_login.html | 44 +++++++++++++++++++ 7 files changed, 68 insertions(+), 7 deletions(-) diff --git a/sigi/apps/diagnosticos/admin.py b/sigi/apps/diagnosticos/admin.py index 3f7b070..02a5064 100644 --- a/sigi/apps/diagnosticos/admin.py +++ b/sigi/apps/diagnosticos/admin.py @@ -56,7 +56,7 @@ class DiagnosticoAdmin(BaseEntityAdmin): date_hierarchy = 'data_questionario' actions = [alterar_status_publicacao, alterar_status_draft] inlines = (EquipeInline, AnexosInline) - list_display = ('casa_legislativa', 'data_questionario', 'status') + list_display = ('casa_legislativa', 'data_questionario', 'responsavel', 'status') raw_id_fields = ('casa_legislativa', 'responsavel') eav_fieldsets = [ diff --git a/sigi/apps/diagnosticos/urls.py b/sigi/apps/diagnosticos/urls.py index 4cb3ae6..6f40dda 100644 --- a/sigi/apps/diagnosticos/urls.py +++ b/sigi/apps/diagnosticos/urls.py @@ -1,10 +1,20 @@ # -*- coding: utf8 -*- from django.conf.urls.defaults import patterns, url +LOGOUT_REDIRECT_URL = '/mobile/diagnosticos/login' + urlpatterns = patterns('', # Lista de Diagnósticos url(r'^$', 'sigi.apps.diagnosticos.views.lista', name='lista_diagnosticos'), + # Login do Diagnóstico + url(r'^login/$', 'django.contrib.auth.views.login', {'template_name': + 'diagnosticos/diagnosticos_login.html'}, name='login'), + + # Logout do Diagnóstico + url(r'^logout/$', 'django.contrib.auth.views.logout', + {'next_page': LOGOUT_REDIRECT_URL}, name='logout'), + # Lista de Categorias url(r'^(?P\d+)/categorias/$', 'sigi.apps.diagnosticos.views.categorias', name='lista_categorias'), diff --git a/sigi/apps/diagnosticos/views.py b/sigi/apps/diagnosticos/views.py index 4233a6b..563d6c3 100644 --- a/sigi/apps/diagnosticos/views.py +++ b/sigi/apps/diagnosticos/views.py @@ -14,7 +14,8 @@ def lista(request): # TODO Implementar pesquisa de diagnosticos, em que esses registros # devem ser criado pelo servidor logado. - diagnosticos = Diagnostico.objects.filter(status=False) + diagnosticos = Diagnostico.objects.filter(status=False).filter( + responsavel=request.user.get_profile()) context = RequestContext(request, {'diagnosticos': diagnosticos}) return render_to_response('diagnosticos/diagnosticos_list.html', context) @@ -44,11 +45,13 @@ def categoria_detalhes(request, id_diagnostico, id_categoria): return render_to_response('mobile/404.html', {}) if request.POST: - form = DiagnosticoMobileForm(request.POST, instance=diagnostico, category=id_categoria) + form = DiagnosticoMobileForm(request.POST, + instance=diagnostico, category=id_categoria) if form.is_valid(): - form.save() + form.save() else: - form = DiagnosticoMobileForm(instance=diagnostico, category=id_categoria) + form = DiagnosticoMobileForm(instance=diagnostico, + category=id_categoria) context = RequestContext(request, {'form': form, 'categoria': categoria, 'diagnostico': diagnostico}) diff --git a/sigi/apps/servidores/admin.py b/sigi/apps/servidores/admin.py index 4c9e5a5..4f8faf7 100644 --- a/sigi/apps/servidores/admin.py +++ b/sigi/apps/servidores/admin.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- from django.contrib import admin +from django.contrib.auth.forms import UserCreationForm from django.contrib.contenttypes import generic from sigi.apps.servidores.models import Servidor, Funcao, Licenca, Ferias from sigi.apps.contatos.models import Endereco, Telefone diff --git a/sigi/settings.py b/sigi/settings.py index e35ffff..a34f0b3 100644 --- a/sigi/settings.py +++ b/sigi/settings.py @@ -98,6 +98,9 @@ AUTH_LDAP_MIRROR_GROUPS = True AUTH_LDAP_CACHE_GROUPS = True AUTH_LDAP_GROUP_CACHE_TIMEOUT = 3600 +# Django Auth Configurations +AUTH_PROFILE_MODULE = 'servidores.Servidor' + # Keep ModelBackend around for per-user permissions and maybe a local superuser. AUTHENTICATION_BACKENDS = ( 'django_auth_ldap.backend.LDAPBackend', diff --git a/sigi/templates/diagnosticos/diagnosticos_list.html b/sigi/templates/diagnosticos/diagnosticos_list.html index 0f63dc9..3a50171 100644 --- a/sigi/templates/diagnosticos/diagnosticos_list.html +++ b/sigi/templates/diagnosticos/diagnosticos_list.html @@ -2,7 +2,7 @@ {% block cabecalho %}

Diagnósticos

- Sair + Sair {% endblock cabecalho %} {% block corpo %} @@ -13,7 +13,7 @@

{{ diagnostico.casa_legislativa.nome }}

Data: {{ diagnostico.data_questionario|date:"d/m/Y" }}

-

Responsável: Nenhum Ainda

+

Responsável: {{ diagnostico.responsavel.nome_completo }}

{% endfor %} diff --git a/sigi/templates/diagnosticos/diagnosticos_login.html b/sigi/templates/diagnosticos/diagnosticos_login.html index e69de29..db17e70 100644 --- a/sigi/templates/diagnosticos/diagnosticos_login.html +++ b/sigi/templates/diagnosticos/diagnosticos_login.html @@ -0,0 +1,44 @@ + + + + + + SIGI - Login de Acesso + + + + + +
+ Interlegis +
+ {% if form.errors %} +
+

Erro ao logar

+
    + {% for field in form %} + {% if field.errors %} +
  • {{ field.errors|striptags }}
  • + {% endif %} + {% endfor %} +
+

Verifique se seu login e senha foram preenchidos corretamente.

+
+ {% endif %} + +
+
+
+ + +
+
+ + +
+ + +
+
+ +