From 4ef868ec9928b4c9aa69cdd12ec88fbddf3f5625 Mon Sep 17 00:00:00 2001 From: Eduardo Calil Date: Tue, 13 Sep 2016 18:17:16 -0300 Subject: [PATCH] Permite acesso da tela de presenca para todos e cria restricoes para as roles --- sapl/sessao/views.py | 10 +++++++--- sapl/templates/sessao/presenca.html | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/sapl/sessao/views.py b/sapl/sessao/views.py index c7462ca77..ae2a02e88 100644 --- a/sapl/sessao/views.py +++ b/sapl/sessao/views.py @@ -2,6 +2,7 @@ from datetime import datetime from re import sub from django.contrib import messages +from django.contrib.auth.decorators import user_passes_test from django.contrib.auth.mixins import PermissionRequiredMixin from django.core.exceptions import ObjectDoesNotExist, ValidationError from django.core.urlresolvers import reverse @@ -43,6 +44,10 @@ OrdemDiaCrud = Crud.build(OrdemDia, '') RegistroVotacaoCrud = Crud.build(RegistroVotacao, '') +def check_permission(user): + return user.has_perms(permissoes_sessao()) + + def reordernar_materias_expediente(request, pk): expedientes = ExpedienteMateria.objects.filter( sessao_plenaria_id=pk) @@ -449,15 +454,14 @@ class PresencaMixin: yield (parlamentar, False) -class PresencaView(PermissionRequiredMixin, - FormMixin, +class PresencaView(FormMixin, PresencaMixin, SessaoCrud.CrudDetailView): template_name = 'sessao/presenca.html' form_class = PresencaForm model = SessaoPlenaria - permission_required = permissoes_sessao() + @user_passes_test(check_permission) def post(self, request, *args, **kwargs): self.object = self.get_object() form = self.get_form() diff --git a/sapl/templates/sessao/presenca.html b/sapl/templates/sessao/presenca.html index 3efb72734..0bdc7f551 100644 --- a/sapl/templates/sessao/presenca.html +++ b/sapl/templates/sessao/presenca.html @@ -1,7 +1,10 @@ {% extends "crud/detail.html" %} {% load i18n %} +{% load common_tags %} {% block detail_content %} + +{% if perms|get_add_perm:view %}
{% csrf_token %} @@ -24,6 +27,22 @@
+ +{% else %} +
+

Parlamentares presentes

+
+
+ + {% for parlamentar, check in view.get_presencas %} +
+
+
+ {% endfor %} + +{% endif %} + + {% endblock detail_content %} {% block extra_js %}