From de6bd0c6a34019db34cea1ec6674005a83fef1bf Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Mon, 5 Sep 2016 11:24:08 -0300 Subject: [PATCH] =?UTF-8?q?Adiciona=20porcetagem=20de=20presen=C3=A7a?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/base/views.py | 14 ++++++++++++++ .../base/RelatorioPresencaSessao_filter.html | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/sapl/base/views.py b/sapl/base/views.py index 0d66f8037..c3acdda65 100644 --- a/sapl/base/views.py +++ b/sapl/base/views.py @@ -30,6 +30,17 @@ class RelatorioPresencaSessaoView(FilterView): filterset_class = RelatorioPresencaSessaoFilterSet template_name = 'base/RelatorioPresencaSessao_filter.html' + def calcular_porcentagem_presenca(self, + parlamentares, + total_sessao, + total_ordem): + for p in parlamentares: + p.update({ + 'porc_sessao': round(p['qtde_sessao'] * 100 / total_sessao, 1), + 'porc_ordem': round(p['qtde_ordem'] * 100 / total_ordem, 1) + }) + return parlamentares + def get_context_data(self, **kwargs): context = super(RelatorioPresencaSessaoView, self).get_context_data(**kwargs) @@ -72,6 +83,9 @@ class RelatorioPresencaSessaoView(FilterView): 'qtde_ordem': qtde_ordem } parlamentares.append(parlamentar) + self.calcular_porcentagem_presenca(parlamentares, + total_sessao, + total_ordem) context['total_ordem'] = total_ordem context['total_sessao'] = total_sessao context['parlamentares'] = parlamentares diff --git a/sapl/templates/base/RelatorioPresencaSessao_filter.html b/sapl/templates/base/RelatorioPresencaSessao_filter.html index 220fe9b01..5d38671bd 100644 --- a/sapl/templates/base/RelatorioPresencaSessao_filter.html +++ b/sapl/templates/base/RelatorioPresencaSessao_filter.html @@ -39,9 +39,9 @@ {{p.nome}} | {{p.partido}} {{p.qtde_sessao}} - -- + {{p.porc_sessao}} {{p.qtde_ordem}} - -- + {{p.porc_ordem}} {% endfor %}