From 361d65fa2c42cba30fada80984e767382dca2a3a Mon Sep 17 00:00:00 2001 From: Cesar Augusto de Carvalho Date: Thu, 29 Aug 2019 11:45:14 -0300 Subject: [PATCH] =?UTF-8?q?Fix=20#2913=20-=20Painel=20eletr=C3=B4nico=20mo?= =?UTF-8?q?dular=20(#2922)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix #2913 - Painel eletrônico modular * Adiciona mudanças sugeridas no PR --- sapl/painel/urls.py | 5 ++- sapl/painel/views.py | 32 +++++++++++++++++- sapl/templates/painel/index.html | 13 +++++++ sapl/templates/sessao/painel.html | 56 +++++++++++++++++++++++++++++-- 4 files changed, 101 insertions(+), 5 deletions(-) diff --git a/sapl/painel/urls.py b/sapl/painel/urls.py index c0d6800e5..e24e94bae 100644 --- a/sapl/painel/urls.py +++ b/sapl/painel/urls.py @@ -4,7 +4,7 @@ from .apps import AppConfig from .views import (cronometro_painel, get_dados_painel, painel_mensagem_view, painel_parlamentar_view, painel_view, painel_votacao_view, switch_painel, verifica_painel, votante_view, CronometroPainelCrud, - PainelConfigCrud) + PainelConfigCrud, painel_parcial_view) app_name = AppConfig.name @@ -27,4 +27,7 @@ urlpatterns = [ url(r'^voto-individual/$', votante_view, name='voto_individual'), + + url(r'^painel-parcial/(?P\d+)/(?P\d+)/$', painel_parcial_view, + name="painel_parcial"), ] diff --git a/sapl/painel/views.py b/sapl/painel/views.py index 50da0563b..78409006b 100644 --- a/sapl/painel/views.py +++ b/sapl/painel/views.py @@ -336,11 +336,41 @@ def votante_view(request): @user_passes_test(check_permission) def painel_view(request, pk): + exibicao = { + 'parlamentares': True, + 'oradores': True, + 'cronometros': True, + 'resultado': True, + 'materia': True + } + context = {'head_title': str(_('Painel Plenário')), + 'sessao_id': pk, + 'cronometros': Cronometro.objects.filter(ativo=True).order_by('ordenacao'), + 'painel_config': PainelConfig.objects.first(), + 'casa': CasaLegislativa.objects.last(), + 'exibicao': exibicao + } + return render(request, 'painel/index.html', context) + +def bit_is_set(number, bit): + return (number & (1 << bit)) != 0 + +@user_passes_test(check_permission) +def painel_parcial_view(request, pk, opcoes): + opcoes = int(opcoes) + exibicao = { + 'parlamentares': bit_is_set(opcoes,0), + 'oradores': bit_is_set(opcoes,1), + 'cronometros': bit_is_set(opcoes, 2), + 'resultado': bit_is_set(opcoes, 3), + 'materia': bit_is_set(opcoes, 4) + } context = {'head_title': str(_('Painel Plenário')), 'sessao_id': pk, 'cronometros': Cronometro.objects.filter(ativo=True).order_by('ordenacao'), 'painel_config': PainelConfig.objects.first(), - 'casa': CasaLegislativa.objects.last() + 'casa': CasaLegislativa.objects.last(), + 'exibicao': exibicao } return render(request, 'painel/index.html', context) diff --git a/sapl/templates/painel/index.html b/sapl/templates/painel/index.html index 0eea79734..e4a6240ed 100644 --- a/sapl/templates/painel/index.html +++ b/sapl/templates/painel/index.html @@ -70,18 +70,25 @@
+ + {% if exibicao.parlamentares %}

Parlamentares

+ {% endif %} +
+ {% if exibicao.oradores %}

Oradores

+ {% endif %} + {% if exibicao.cronometros %}

{% if cronometros|length == 1 %}Cronômetro{% elif cronometros|length > 1%}Cronômetros{% endif %}

@@ -90,17 +97,23 @@ {% endfor %}
+ {% endif %} + + {% if exibicao.resultado %}

Resultado

+ {% endif %} + {% if exibicao.materia %}

Matéria em Votação

+ {% endif %}