Browse Source

Muda o dashboard de context processor para view e melhora a sua apresentação

whois_api
Sesostris Vieira 9 years ago
parent
commit
572970d928
  1. 7
      sigi/apps/home/urls.py
  2. 41
      sigi/apps/home/views.py
  3. 1
      sigi/settings/base.py
  4. 2
      sigi/urls.py
  5. 5
      sigiStatic/css/base_site.css
  6. 8
      templates/admin/base_site.html
  7. 154
      templates/index.html
  8. 70
      templates/snippets/modules/charts-convenios.html

7
sigi/apps/home/urls.py

@ -0,0 +1,7 @@
# coding: utf-8
from django.conf.urls import patterns, url
urlpatterns = patterns('sigi.apps.home.views',
url(r'^$', 'index', name='sigi_index'),
)

41
sigi/context_processors.py → sigi/apps/home/views.py

@ -1,21 +1,42 @@
# -*- coding: utf-8 -*-
from itertools import cycle
#
# sigi.apps.home.views
#
# Copyright (c) 2016 by Interlegis
#
# GNU General Public License (GPL)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
#
import datetime
from django.shortcuts import render
from django.utils.translation import ugettext as _
from itertools import cycle
from sigi.apps.casas.models import CasaLegislativa
from sigi.apps.convenios.models import Convenio, Projeto
from sigi.apps.diagnosticos.models import Diagnostico
from sigi.apps.metas.models import Meta
from sigi.apps.servicos.models import TipoServico
from django.views.decorators.cache import never_cache
from django.contrib.auth.decorators import login_required
def charts_data(request):
"""
Busca informacoes para a criacao dos graficos e resumos
"""
@never_cache
@login_required
def index(request):
convenios = Convenio.objects.all()
convenios_assinados = convenios.exclude(data_retorno_assinatura=None)
@ -24,14 +45,14 @@ def charts_data(request):
tabela_resumo_diagnostico = busca_informacoes_diagnostico()
dados_graficos_convenio_projeto = [(1, grafico_convenio_projeto(convenios)),
(2, grafico_convenio_projeto(convenios_assinados))]
return {
context = {
'tabela_resumo_camara': tabela_resumo_camara,
'tabela_resumo_seit': tabela_resumo_seit,
'tabela_resumo_diagnostico': tabela_resumo_diagnostico,
'dados_graficos_convenio_projeto': dados_graficos_convenio_projeto,
'metas': Meta.objects.all(),
}
return render(request, 'index.html', context)
def busca_informacoes_camara():
"""

1
sigi/settings/base.py

@ -31,7 +31,6 @@ MANAGERS = ADMINS
SITE_ID = 1
TEMPLATE_CONTEXT_PROCESSORS = DEFAULT_SETTINGS.TEMPLATE_CONTEXT_PROCESSORS + (
'sigi.context_processors.charts_data',
'django.core.context_processors.request',
)
# List of callables that know how to import templates from various sources.

2
sigi/urls.py

@ -25,7 +25,7 @@ urlpatterns = patterns(
url(r'^ocorrencias/', include('sigi.apps.ocorrencias.urls')),
url(r'^eventos/', include('sigi.apps.eventos.urls')),
url(r'^pentaho/(?P<path>(plugin|api)/.*)$', pentaho_proxy),
url(r'^', include('sigi.apps.home.urls')),
url(r'^', include(admin.site.urls)),
# to enable language selection

5
sigiStatic/css/base_site.css

@ -233,3 +233,8 @@ h1 {
.container-flex > div[class*='col-'] #map div, .row-flex > div[class*='col-'] #map div {
width: initial;
}
.pilllabel {
display: block;
padding: 10px;
}

8
templates/admin/base_site.html

@ -54,14 +54,6 @@
<p>{% trans 'É recomendado o uso das informações aqui fornecidas fora do âmbito do Interlegis' %}.</p>
<p>{% trans 'SIGI é um software livre e seus fontes estão disponíveis no' %} <a href="http://colab.interlegis.leg.br/wiki/ProjetoSigi">Colab</a>.</p>
</div>
<div class="footerlogos">
<ul>
<li><a href="http://www.senado.leg.br"><img title="Senado Federal" alt="Logotipo do Senado Federal" src="http://www.interlegis.leg.br/++theme++il.portalinterlegis/images/senado.png"></a></li>
<li><a href="http://www.camara.leg.br"><img title="Câmara dos Deputados" alt="Logotipo da Câmara dos Deputados" src="http://www.interlegis.leg.br/++theme++il.portalinterlegis/images/camara.png"></a></li>
<li><a href="http://www.iadb.org/pt"><img title="Banco Interamericano de Desenvolvimento" alt="Logotipo do Banco Interamericano de Desenvolvimento" src="http://www.interlegis.leg.br/++theme++il.portalinterlegis/images/bid.png"></a></li>
<li><a href="http://www.tcu.leg.br"><img title="Tribunal de Contas da União" alt="Logotipo do Tribunal de Contas da União" src="http://www.interlegis.leg.br/++theme++il.portalinterlegis/images/tcu.png"></a></li>
</ul>
</div>
</div>
{% endif %}

154
templates/index.html

@ -12,48 +12,11 @@
<script type="text/javascript" src="{% static 'admin/js/jquery.min.js' %}" ></script>
<script type="text/javascript" src="{% static 'admin/js/jquery.init.js' %}" ></script>
<script type="text/javascript" src="{% static 'js/Chart.min.js' %}" ></script>
<script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=false"> </script>
<script type="text/javascript">
(function($) {
$(document).ready(function($) {
var latlng = new google.maps.LatLng(-14.2350040, -51.925280);
var myOptions = {
zoom: 3,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
$.get("/diagnosticos/mundiagjson/", function(municipios) {
for (var i in municipios) {
var municipio = municipios[i];
var markData = {
map: map,
position: new google.maps.LatLng(municipio.lat, municipio.lng),
title: municipio.nome,
icon: "{% static 'img/mapmarker.png' %}"
}
var mark = new google.maps.Marker(markData);
var infoWin = new google.maps.InfoWindow({content:
'<strong>' + municipio.nome + '</strong><br/>' +
'<strong>Início da visita:</strong><br/>' + municipio.inicio + '<br/>' +
'<strong>Término da visita:</strong><br/>' + municipio.fim + '<br/>' +
'<strong>Equipe:</trong><br/>' + municipio.equipe });
linkMarkMessage(mark, infoWin, map);
}
});
function linkMarkMessage(mark, infoWin, map) {
google.maps.event.addListener(mark, 'click', function() {
infoWin.open(map, mark);});
}
})
})(django.jQuery);
</script>
<script>
$(document).ready(function () {
var pieData = {
{% for num, dados in dados_graficos_convenio_projeto %}
var pieData{{ num }} = [
{{ num }}: [
{% for label, value, color, highlight in dados %}
{
label: "{{ label }}",
@ -62,110 +25,17 @@
highlight: "{{ highlight }}"
},
{% endfor %}
]
window.onload = function(){
var canvas1 = document.getElementById("canvas-holder-1");
var ctx = document.getElementById("chart-area-1").getContext("2d");
window.myPie = new Chart(ctx).Pie(pieData1).generateLegend();
var legendHolder = document.createElement('div');
legendHolder.innerHTML = myPie;
canvas1.appendChild(legendHolder.firstChild);
var canvas2 = document.getElementById("canvas-holder-2");
var ctx2 = document.getElementById("chart-area-2").getContext("2d");
window.myPie2 = new Chart(ctx2).Pie(pieData2);
var legendHolder2 = document.createElement('div');
legendHolder2.innerHTML = myPie2.generateLegend();
canvas2.appendChild(legendHolder2.firstChild);
};
],
{% endfor %}
};
$.each(pieData, function(num, data) {
var canvas = $("#canvas-holder-"+num);
var ctx = $("#chart-area-"+num).get(0).getContext("2d");
var myPie = new Chart(ctx).Pie(data);
canvas.append('<div>'+myPie.generateLegend()+'</div>');
});
});
</script>
{# Highcharts scripts #}
{# <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>#}
{# <script src="http://code.highcharts.com/highcharts.js"></script>#}
{##}
{# <script type="text/javascript">#}
{# $(function () {#}
{# var chart;#}
{##}
{# $(document).ready(function () {#}
{##}
{# // Build the chart#}
{# $('#processos_conv').highcharts({#}
{# chart: {#}
{# plotBackgroundColor: null,#}
{# plotBorderWidth: null,#}
{# plotShadow: false#}
{# },#}
{# title: {#}
{# text: 'Processos de convênios por projeto <br/> {{ g_conv_proj.0 }}'#}
{# },#}
{# tooltip: {#}
{# pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'#}
{# },#}
{# plotOptions: {#}
{# pie: {#}
{# allowPointSelect: true,#}
{# cursor: 'pointer',#}
{# dataLabels: {#}
{# enabled: false#}
{# },#}
{# showInLegend: true#}
{# }#}
{# },#}
{# series: [{#}
{# type: 'pie',#}
{# name: 'Browser share',#}
{# data: [#}
{# {% for k, v in g_conv_proj %}#}
{# {% if not forloop.first %}#}
{# ['{{ k }}', {{ v }}],#}
{# {% endif %}#}
{# {% endfor %}#}
{# ]#}
{# }]#}
{# });#}
{# $('#processos_conv_ass').highcharts({#}
{# chart: {#}
{# plotBackgroundColor: null,#}
{# plotBorderWidth: null,#}
{# plotShadow: false#}
{# },#}
{# title: {#}
{# text: 'Convênios assinados por projeto <br/> {{ g_convassinado_proj.0 }}'#}
{# },#}
{# tooltip: {#}
{# pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'#}
{# },#}
{# plotOptions: {#}
{# pie: {#}
{# allowPointSelect: true,#}
{# cursor: 'pointer',#}
{# dataLabels: {#}
{# enabled: false#}
{# },#}
{# showInLegend: true#}
{# }#}
{# },#}
{# series: [{#}
{# type: 'pie',#}
{# name: 'Browser share',#}
{# data: [#}
{# {% for k, v in g_convassinado_proj %}#}
{# {% if not forloop.first %}#}
{# ['{{ k }}', {{ v }}],#}
{# {% endif %}#}
{# {% endfor %}#}
{# ]#}
{# }]#}
{# });#}
{# });#}
{##}
{# });#}
{# </script>#}
{# end highcharts scripts #}
<style type="text/css">

70
templates/snippets/modules/charts-convenios.html

@ -2,17 +2,28 @@
{% load i18n %}
<div class="row row-flex row-flex-wrap">
<div class="col-md-5">
<div class="col-md-6">
<div class="panel panel-primary flex-col">
<div class="panel-heading">{% trans 'Resumo de informações' %}</div>
<div class="panel-body table-responsive">
<dl class="dl-horizontal">
<dt class="pilllabel">{% trans 'Resumo por região' %}:</dt>
<dd>
<ul class="nav nav-pills">
<li><a href="{% url 'convenios-report_regiao_pdf' 'CO' %}">Centro Oeste</a></li>
<li><a href="{% url 'convenios-report_regiao_pdf' 'NE' %}">Nordeste</a></li>
<li><a href="{% url 'convenios-report_regiao_pdf' 'NO' %}">Norte</a></li>
<li><a href="{% url 'convenios-report_regiao_pdf' 'SD' %}">Sudeste</a></li>
<li><a href="{% url 'convenios-report_regiao_pdf' 'SL' %}">Sul</a></li>
</ul>
</dd>
</dl>
<table class="table table-condensed numeros">
<tr>
{% for item in tabela_resumo_camara.cabecalho_topo %}
<th>{{item}}</th>
{% endfor %}
</tr>
{% for cabecalho,lista in tabela_resumo_camara.lista_zip %}
<tr>
<th>{{cabecalho}}</th>
@ -22,6 +33,7 @@
</tr>
{% endfor %}
</table>
</div>
<div class="panel-footer">
<dl class="dl-horizontal">
<dt>{% trans 'Câmaras sem processo' %}</dt>
@ -35,27 +47,13 @@
</div>
</div>
<div class="col-md-3">
<div class="panel panel-primary flex-col">
<div class="panel-heading">{% trans 'Convênios assinados por projeto' %}</div>
<div class="panel-body">
<div id="canvas-holder-1">
<canvas id="chart-area-1" width="150" height="150" />
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="col-md-6">
<div class="panel panel-primary flex-col">
<div class="panel-heading">{% trans 'Serviços hospedados no Interlegis (SEIT)' %}</div>
<div class="panel-body">
<div class="titlemapbox">
<div class="mapbox"><a href="/dashboard/mapa/"><img src="{% static 'img/mapicon.png' %}" /><br/>{% trans 'Ver mapa' %}</a></div>
</div>
</div>
<table class="table table-condensed numeros servicos">
{% for servico in tabela_resumo_seit %}
<tr>
@ -66,9 +64,7 @@
<th>{{ servico.novos_mes_atual }}</th>
{% else %}
<th class="dropdown">
<a id="ddm-{{ servico.nome }}" data-toggle="dropdown" href="#">
{{ servico.nome }}
</a>
<a id="ddm-{{ servico.nome }}" data-toggle="dropdown" href="#">{{ servico.nome }}</a>
<table class="table table-condensed numeros servicos dropdown-menu" role="menu" aria-labelledby="ddm-{{ servico.nome }}">
{% for mes in servico.novos_por_mes %}
<tr><th>{{ mes.mes }}</th><td>{{ mes.total }}</td></tr>
@ -85,28 +81,21 @@
</div>
</div>
</div>
</div>
<div class="row row-flex row-flex-wrap">
<div class="col-md-5">
<div class="col-md-6">
<div class="panel panel-primary flex-col">
<div class="panel-heading">{% trans 'Resumo de informações por região' %}</div>
<div class="panel-heading">{% trans 'Convênios assinados por projeto' %}</div>
<div class="panel-body">
<p>
{% trans 'Resumo de informações de Câmaras Municipais por região levando em conta apenas o Projeto Interlegis' %}.
{% trans 'Demais projetos como PPM e PML não estão inclusos' %}.
</p>
<ul class="conteudo_regiao">
<li><a href="{% url 'convenios-report_regiao_pdf' 'CO' %}">Centro Oeste</a></li>
<li><a href="{% url 'convenios-report_regiao_pdf' 'NE' %}">Nordeste</a></li>
<li><a href="{% url 'convenios-report_regiao_pdf' 'NO' %}">Norte</a></li>
<li><a href="{% url 'convenios-report_regiao_pdf' 'SD' %}">Sudeste</a></li>
<li><a href="{% url 'convenios-report_regiao_pdf' 'SL' %}">Sul</a></li>
</ul>
<div id="canvas-holder-1">
<canvas id="chart-area-1" width="150" height="150" />
</div>
</div>
</div>
</div>
<div class="col-md-3">
<div class="col-md-6">
<div class="panel panel-primary flex-col">
<div class="panel-heading">{% trans 'Processos de convênios por projeto' %}</div>
<div class="panel-body">
@ -116,16 +105,7 @@
</div>
</div>
</div>
<div class="col-md-4">
<div class="panel panel-primary flex-col">
<div class="panel-heading">{% trans 'Mapa de atuação do Interlegis' %}</div>
<div class="panel-body">
<div id="dashboard-mapa" class="align-center">
<a href="/dashboard/mapa/"> <img src="{% static 'img/mapicon-large.png' %}"/> </a>
</div>
</div>
</div>
</div>
</div>

Loading…
Cancel
Save