Browse Source

Resolve bug nas permissoes de presenca

pull/585/head
Eduardo Calil 8 years ago
parent
commit
0bbbe4951b
  1. 16
      sapl/sessao/views.py
  2. 4
      sapl/templates/sessao/presenca.html
  3. 21
      sapl/templates/sessao/presenca_ordemdia.html

16
sapl/sessao/views.py

@ -2,7 +2,6 @@ from datetime import datetime
from re import sub from re import sub
from django.contrib import messages from django.contrib import messages
from django.contrib.auth.decorators import user_passes_test
from django.contrib.auth.mixins import PermissionRequiredMixin from django.contrib.auth.mixins import PermissionRequiredMixin
from django.core.exceptions import ObjectDoesNotExist, ValidationError from django.core.exceptions import ObjectDoesNotExist, ValidationError
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
@ -44,10 +43,6 @@ OrdemDiaCrud = Crud.build(OrdemDia, '')
RegistroVotacaoCrud = Crud.build(RegistroVotacao, '') RegistroVotacaoCrud = Crud.build(RegistroVotacao, '')
def check_permission(user):
return user.has_perms(permissoes_sessao())
def reordernar_materias_expediente(request, pk): def reordernar_materias_expediente(request, pk):
expedientes = ExpedienteMateria.objects.filter( expedientes = ExpedienteMateria.objects.filter(
sessao_plenaria_id=pk) sessao_plenaria_id=pk)
@ -461,11 +456,13 @@ class PresencaView(FormMixin,
form_class = PresencaForm form_class = PresencaForm
model = SessaoPlenaria model = SessaoPlenaria
@user_passes_test(check_permission)
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
self.object = self.get_object() self.object = self.get_object()
form = self.get_form() form = self.get_form()
if not self.request.user.has_perms(permissoes_sessao()):
return self.form_invalid(form)
if form.is_valid(): if form.is_valid():
# Pegar os presentes salvos no banco # Pegar os presentes salvos no banco
presentes_banco = SessaoPlenariaPresenca.objects.filter( presentes_banco = SessaoPlenariaPresenca.objects.filter(
@ -503,13 +500,11 @@ class PainelView(PermissionRequiredMixin, TemplateView):
permission_required = permissoes_painel() permission_required = permissoes_painel()
class PresencaOrdemDiaView(PermissionRequiredMixin, class PresencaOrdemDiaView(FormMixin,
FormMixin,
PresencaMixin, PresencaMixin,
SessaoCrud.CrudDetailView): SessaoCrud.CrudDetailView):
template_name = 'sessao/presenca_ordemdia.html' template_name = 'sessao/presenca_ordemdia.html'
form_class = PresencaForm form_class = PresencaForm
permission_required = permissoes_sessao()
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
@ -518,6 +513,9 @@ class PresencaOrdemDiaView(PermissionRequiredMixin,
pk = kwargs['pk'] pk = kwargs['pk']
if not self.request.user.has_perms(permissoes_sessao()):
return self.form_invalid(form)
if form.is_valid(): if form.is_valid():
# Pegar os presentes salvos no banco # Pegar os presentes salvos no banco
presentes_banco = PresencaOrdemDia.objects.filter( presentes_banco = PresencaOrdemDia.objects.filter(

4
sapl/templates/sessao/presenca.html

@ -35,9 +35,11 @@
</br> </br>
{% for parlamentar, check in view.get_presencas %} {% for parlamentar, check in view.get_presencas %}
{% if check %}
<div class="row"> <div class="row">
<div class="col-md-6"><label for="parlamentar">{{ forloop.counter }} - {{ parlamentar }}</label></div> <div class="col-md-6"><label for="parlamentar"> - {{ parlamentar }}</label></div>
</div> </div>
{% endif %}
{% endfor %} {% endfor %}
{% endif %} {% endif %}

21
sapl/templates/sessao/presenca_ordemdia.html

@ -1,7 +1,10 @@
{% extends "crud/detail.html" %} {% extends "crud/detail.html" %}
{% load i18n %} {% load i18n %}
{% load common_tags %}
{% block detail_content %} {% block detail_content %}
{% if perms|get_add_perm:view %}
<form method="POST"> <form method="POST">
{% csrf_token %} {% csrf_token %}
@ -24,6 +27,24 @@
<br /> <br />
<input type="submit" value="Salvar" class="btn btn-primary" /> <input type="submit" value="Salvar" class="btn btn-primary" />
</form> </form>
{% else %}
<div class="row">
<div class="col-md-6"><h2>Parlamentares presentes</div>
</div>
</br>
{% for parlamentar, check in view.get_presencas_ordem %}
{% if check %}
<div class="row">
<div class="col-md-6"><label for="parlamentar"> - {{ parlamentar }}</label></div>
</div>
{% endif %}
{% endfor %}
{% endif %}
{% endblock detail_content %} {% endblock detail_content %}
{% block extra_js %} {% block extra_js %}

Loading…
Cancel
Save