From 2d69950bee6bb74ba4b916de1221691df859bf21 Mon Sep 17 00:00:00 2001 From: Guilherme Gondim Date: Thu, 8 Jan 2009 19:04:11 +0000 Subject: [PATCH] =?UTF-8?q?Adicionado=20gr=C3=A1ficos=20de=20conv=C3=AAnio?= =?UTF-8?q?s=20no=20Dashboard=20com=20django-googlecharts.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sigi/context_processors.py | 32 ++++++++++++++++++ sigi/settings.py | 3 +- sigi/templates/index.html | 68 ++++++++++++++++++++------------------ 3 files changed, 69 insertions(+), 34 deletions(-) create mode 100644 sigi/context_processors.py diff --git a/sigi/context_processors.py b/sigi/context_processors.py new file mode 100644 index 0000000..be1c40b --- /dev/null +++ b/sigi/context_processors.py @@ -0,0 +1,32 @@ +from sigi.apps.casas.models import CasaLegislativa +from sigi.apps.convenios.models import Convenio + +def charts_data(request): + casas = CasaLegislativa.objects.all() + convenios = Convenio.objects.all() + convenios_firmados = convenios.exclude(data_retorno_assinatura=None) + + num_convenios_firmados = convenios_firmados.count() + num_convenios_nao_firmados = convenios.filter(data_retorno_assinatura=None).count() + num_casas_nao_aderidas = casas.count() - convenios.exclude(data_adesao=None).count() + + num_casas_regiao = [ + casas.filter(municipio__uf__regiao='CO').count(), + casas.filter(municipio__uf__regiao='NO').count(), + casas.filter(municipio__uf__regiao='NE').count(), + casas.filter(municipio__uf__regiao='SD').count(), + casas.filter(municipio__uf__regiao='SL').count() + ] + num_convenios_firmados_regiao = [ + convenios_firmados.filter(casa_legislativa__municipio__uf__regiao='CO').count(), + convenios_firmados.filter(casa_legislativa__municipio__uf__regiao='NO').count(), + convenios_firmados.filter(casa_legislativa__municipio__uf__regiao='NE').count(), + convenios_firmados.filter(casa_legislativa__municipio__uf__regiao='SD').count(), + convenios_firmados.filter(casa_legislativa__municipio__uf__regiao='SL').count() + ] + + return { + 'regioes_chart_data': [num_convenios_firmados_regiao, num_casas_regiao], + 'convenios_chart_data': [num_convenios_firmados, num_convenios_nao_firmados, + num_casas_nao_aderidas] + } diff --git a/sigi/settings.py b/sigi/settings.py index bf81d1e..d1c880f 100644 --- a/sigi/settings.py +++ b/sigi/settings.py @@ -57,6 +57,7 @@ TEMPLATE_CONTEXT_PROCESSORS = ( 'django.core.context_processors.debug', 'django.core.context_processors.i18n', 'django.core.context_processors.media', + 'sigi.context_processors.charts_data', ) MIDDLEWARE_CLASSES = ( @@ -87,7 +88,7 @@ INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.admindocs', 'django_extensions', # http://django-command-extensions.googlecode.com/ - 'GChartWrapper.charts', + 'googlecharts', 'sigi.apps.casas', 'sigi.apps.contatos', 'sigi.apps.convenios', diff --git a/sigi/templates/index.html b/sigi/templates/index.html index 874f1f6..814439b 100644 --- a/sigi/templates/index.html +++ b/sigi/templates/index.html @@ -1,44 +1,46 @@ {% extends "admin/index.html" %} -{% load i18n %} +{% load charts i18n %} {% block title %}Dashboard | SIGI{% endblock %} {% block content_title %}

Dashboard

{% endblock %} {% block content %} + +{% chart as convenios %} + {% chart-size 340 160 %} + {% chart-type "pie" %} + {% chart-labels "Conveniadas" "Não conveniadas" "Não aderidas" %} + {% chart-data convenios_chart_data %} +{% endchart %} + +{% chart as regioes %} + {% chart-size 320 160 %} + {% chart-type "column-stacked" %} + {% chart-bar-width "40" %} + {% chart-labels "Centro-O" "Norte" "Nordeste" "Sudeste" "Sul" %} + {% chart-data regioes_chart_data.0 regioes_chart_data.1 %} + {% chart-legend "Conveniadas" "Total" %} + {% chart-colors "ff9900,ffc266" %} +{% endchart %} +
-{% if app_list %} - {% for app in app_list %} -
- - - {% for model in app.models %} - - {% if model.perms.change %} - - {% else %} - - {% endif %} - - {% if model.perms.add %} - - {% else %} - - {% endif %} - - {% if model.perms.change %} - - {% else %} - - {% endif %} - - {% endfor %} -
{% blocktrans with app.name as name %}{{ name }}{% endblocktrans %}
{{ model.name }}{{ model.name }}{% trans 'Add' %} {% trans 'Change' %} 
-
- {% endfor %} -{% else %} -

{% trans "You don't have permission to edit anything." %}

-{% endif %} +
+

Convênios

+

Convênios com as Casas Legislativas

+

+ +

+
+ +
+

Convênios

+

Casas Legislativas conveniadas por região

+

+ +

+
+
{% endblock %}