-
-
Sim: {{ resultado.numero_votos.votos_sim }}
- Não: {{ resultado.numero_votos.votos_nao }}
- Abstenções: {{ resultado.numero_votos.abstencoes }}
- Presentes: {{ resultado.numero_votos.num_presentes }}
- Total votos: {{ resultado.numero_votos.total_votos }}
-
-
{{ resultado.resultado_votacao }}
+
+
+
+
+
+ Presentes
+ {{ numPresentes }}
+
+
+ Sim
+ {{ votosSim }}
+
+
+ Não
+ {{ votosNao }}
+
+
+ Abstenções
+ {{ votosAbstencao }}
+
+
+ Total votos
+ {{ totalVotos }}
+
+
+
@@ -28,18 +35,6 @@ export default {
name: 'PainelResultado',
data() {
return {
- /*
- resultado: {
- numero_votos: {
- votos_sim: 0,
- votos_nao: 0,
- abstencoes: 0,
- total_votos: 0,
- num_presentes: 0,
- },
- resultado_votacao: '',
- }
- */
};
},
mounted() {
@@ -50,20 +45,64 @@ export default {
canRender () {
return this.sessao_aberta && this.painel_aberto;
},
- ...mapState(["painel_aberto", "sessao_aberta", "resultado"])
- },
- methods: {
- changeFontSize(value) {
- const el = this.$refs.votacao;
- if (!el) return;
- let fontSize = window.getComputedStyle(el).fontSize;
- fontSize = parseFloat(fontSize); // safely convert "16px" → 16
- el.style.fontSize = (fontSize + value) + 'px';
+ ...mapState(["painel_aberto", "sessao_aberta", "resultado", "parlamentares"]),
+ numPresentes() {
+ if (this.resultado && this.resultado.numero_votos && typeof this.resultado.numero_votos.num_presentes !== 'undefined' && this.resultado.numero_votos.num_presentes !== null) {
+ return this.resultado.numero_votos.num_presentes;
+ }
+ return this.parlamentares ? this.parlamentares.length : 0;
+ },
+ votosSim() {
+ if (this.resultado && this.resultado.numero_votos && typeof this.resultado.numero_votos.votos_sim !== 'undefined' && this.resultado.numero_votos.votos_sim !== null && this.resultado.numero_votos.votos_sim > 0) {
+ return this.resultado.numero_votos.votos_sim;
+ }
+ return this.parlamentares ? this.parlamentares.filter(p => p.voto === 'Sim').length : 0;
},
- }
+ votosNao() {
+ if (this.resultado && this.resultado.numero_votos && typeof this.resultado.numero_votos.votos_nao !== 'undefined' && this.resultado.numero_votos.votos_nao !== null && this.resultado.numero_votos.votos_nao > 0) {
+ return this.resultado.numero_votos.votos_nao;
+ }
+ return this.parlamentares ? this.parlamentares.filter(p => p.voto === 'Não').length : 0;
+ },
+ votosAbstencao() {
+ if (this.resultado && this.resultado.numero_votos && typeof this.resultado.numero_votos.abstencoes !== 'undefined' && this.resultado.numero_votos.abstencoes !== null && this.resultado.numero_votos.abstencoes > 0) {
+ return this.resultado.numero_votos.abstencoes;
+ }
+ return this.parlamentares ? this.parlamentares.filter(p => p.voto === 'Abstenção').length : 0;
+ },
+ totalVotos() {
+ if (this.resultado && this.resultado.numero_votos && typeof this.resultado.numero_votos.total_votos !== 'undefined' && this.resultado.numero_votos.total_votos !== null && this.resultado.numero_votos.total_votos > 0) {
+ return this.resultado.numero_votos.total_votos;
+ }
+ return this.votosSim + this.votosNao + this.votosAbstencao;
+ }
+ },
};
\ No newline at end of file
diff --git a/sapl/painel/consumers.py b/sapl/painel/consumers.py
index 0e6f06b97..895a4844e 100644
--- a/sapl/painel/consumers.py
+++ b/sapl/painel/consumers.py
@@ -65,6 +65,29 @@ def get_dados_painel(sessao_plenaria_id: int) -> dict:
'nome_parlamentar',
'filiacao', )
parlamentares = [dict(zip(['parlamentar_id', 'nome_parlamentar', 'filiacao'], p)) for p in presentes]
+
+ # Adicionar fotografia dos parlamentares
+ from sapl.parlamentares.models import Parlamentar
+ from image_cropping.utils import get_backend
+ parlamentar_ids = [p['parlamentar_id'] for p in parlamentares]
+ parlamentares_db = {p.id: p for p in Parlamentar.objects.filter(id__in=parlamentar_ids)}
+ for p in parlamentares:
+ par = parlamentares_db.get(p['parlamentar_id'])
+ if par and par.fotografia:
+ try:
+ p['fotografia'] = get_backend().get_thumbnail_url(
+ par.fotografia,
+ {
+ 'size': (128, 128),
+ 'box': par.cropping,
+ 'crop': True,
+ 'detail': True,
+ }
+ )
+ except Exception:
+ p['fotografia'] = None
+ else:
+ p['fotografia'] = None
if materia_votacao and materia_votacao.numero_votos:
materia_votacao.numero_votos.update({"num_presentes": len(parlamentares)})
diff --git a/sapl/painel/views.py b/sapl/painel/views.py
index 53abaa1de..fe227740f 100644
--- a/sapl/painel/views.py
+++ b/sapl/painel/views.py
@@ -13,6 +13,7 @@ from django.shortcuts import render
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
+from sapl import settings
from sapl.base.models import AppConfig as ConfiguracoesAplicacao
from sapl.base.models import CasaLegislativa
from sapl.crud.base import Crud
@@ -23,6 +24,7 @@ from sapl.sessao.models import (ExpedienteMateria, OradorExpediente, OrdemDia,
SessaoPlenaria, SessaoPlenariaPresenca,
VotoParlamentar, RegistroLeitura)
from sapl.utils import filiacao_data, get_client_ip, sort_lista_chave
+from image_cropping.utils import get_backend
from .models import Cronometro
@@ -402,10 +404,24 @@ def get_presentes(pk, response, materia):
else:
partido = filiacao
+
+ if p.parlamentar.fotografia:
+ thumbnail_url = get_backend().get_thumbnail_url(
+ p.parlamentar.fotografia,
+ {
+ 'size': (128, 128),
+ 'box': p.parlamentar.cropping,
+ 'crop': True,
+ 'detail': True,
+ }
+ )
+ else:
+ thumbnail_url = False
presentes_list.append(
{'id': p.id,
'parlamentar_id': p.parlamentar.id,
'nome': p.parlamentar.nome_parlamentar,
+ 'fotografia':thumbnail_url,
'partido': partido,
'voto': ''
})
diff --git a/sapl/sessao/migrations/0070_views_sessao_plenaria.py b/sapl/sessao/migrations/0070_views_sessao_plenaria.py
index 74c0be100..4e8791ac5 100644
--- a/sapl/sessao/migrations/0070_views_sessao_plenaria.py
+++ b/sapl/sessao/migrations/0070_views_sessao_plenaria.py
@@ -186,14 +186,14 @@ class Migration(migrations.Migration):
LEFT JOIN LATERAL (
SELECT em.sessao_plenaria_id,
em.numero_ordem,
- jsonb_agg(jsonb_build_object(
+ jsonb_object_agg(
vp.parlamentar_id,
jsonb_build_object(
'materia_id', em.materia_id,
'parlamentar_id', vp.parlamentar_id,
'parlamentar_nome', p.nome_parlamentar,
'voto', vp.voto
- )) ORDER BY p.nome_parlamentar) as votos_parlamentares
+ )) as votos_parlamentares
FROM sessao_votoparlamentar vp
JOIN parlamentares_parlamentar p ON (vp.parlamentar_id = p.id)
WHERE vp.expediente_id = em.id AND em.tipo_votacao != 4
@@ -227,7 +227,7 @@ class Migration(migrations.Migration):
FROM sessao_ordemdia od
JOIN materia_materialegislativa ml ON (od.materia_id = ml.id)
JOIN materia_tipomaterialegislativa tm ON (ml.tipo_id = tm.id)
- LEFT JOIN sessao_registroleitura rl on (od.id = rl.expediente_id)
+ LEFT JOIN sessao_registroleitura rl on (od.id = rl.ordem_id)
LEFT JOIN LATERAL (
SELECT jsonb_build_object(
'votos_sim', coalesce(rv.numero_votos_sim, 0),
@@ -238,21 +238,21 @@ class Migration(migrations.Migration):
trv.nome resultado_votacao
FROM sessao_registrovotacao rv
JOIN sessao_tiporesultadovotacao trv on (rv.tipo_resultado_votacao_id = trv.id)
- WHERE rv.expediente_id = od.id AND tipo_votacao != 4) rv ON TRUE
+ WHERE rv.ordem_id = od.id AND tipo_votacao != 4) rv ON TRUE
LEFT JOIN LATERAL (
SELECT od.sessao_plenaria_id,
od.numero_ordem,
- jsonb_agg(jsonb_build_object(
+ jsonb_object_agg(
vp.parlamentar_id,
jsonb_build_object(
'materia_id', od.materia_id,
'parlamentar_id', vp.parlamentar_id,
'parlamentar_nome', p.nome_parlamentar,
'voto', vp.voto
- )) ORDER BY p.nome_parlamentar) as votos_parlamentares
+ )) as votos_parlamentares
FROM sessao_votoparlamentar vp
JOIN parlamentares_parlamentar p ON (vp.parlamentar_id = p.id)
- WHERE vp.expediente_id = od.id AND od.tipo_votacao != 4
+ WHERE vp.ordem_id = od.id AND od.tipo_votacao != 4
GROUP BY od.sessao_plenaria_id, od.numero_ordem
ORDER BY od.sessao_plenaria_id, od.numero_ordem
) vp ON TRUE
diff --git a/sapl/templates/painel/painel_v2.html b/sapl/templates/painel/painel_v2.html
index e8ceeb76e..ee5360311 100644
--- a/sapl/templates/painel/painel_v2.html
+++ b/sapl/templates/painel/painel_v2.html
@@ -5,86 +5,57 @@
{% load webpack_static from webpack_loader %}
-
-
-
-
{% block head_title %}{% trans 'SAPL - Sistema de Apoio ao Processo Legislativo' %}{% endblock %}
-
+
+
{% block webpack_loader_css %}
{% render_chunk_vendors 'css' %}
{% render_bundle 'global' 'css' %}
{% render_bundle 'painel' 'css' %}
{% endblock webpack_loader_css %}
-
-
-
-
+
{% block vue_content %}
-
+
+
-
-
-
+
-
-
+
+
-
-
-
-
Cronômetros
-
-
-
- A-
-
-
- A+
-
-
-
-
-
-
-
-
+
-
-
-
+
Tema da Sessão Solene
-
+ [[ sessao.tema_solene ]]
+
+
+
-
{% endblock %}
{% block webpack_loader_js %}