Browse Source

Adicionado gráficos de convênios no Dashboard com django-googlecharts.

0.2
Guilherme Gondim 16 years ago
parent
commit
2d69950bee
  1. 32
      sigi/context_processors.py
  2. 3
      sigi/settings.py
  3. 64
      sigi/templates/index.html

32
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]
}

3
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',

64
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 %}<h1>Dashboard</h1>{% 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 %}
<div id="content-main">
{% if app_list %}
{% for app in app_list %}
<div class="module">
<table summary="{% blocktrans with app.name as name %}Models available in the {{ name }} application.{% endblocktrans %}">
<caption><a href="{{ app.app_url }}" class="section">{% blocktrans with app.name as name %}{{ name }}{% endblocktrans %}</a></caption>
{% for model in app.models %}
<tr>
{% if model.perms.change %}
<th scope="row"><a href="{{ model.admin_url }}">{{ model.name }}</a></th>
{% else %}
<th scope="row">{{ model.name }}</th>
{% endif %}
{% if model.perms.add %}
<td><a href="{{ model.admin_url }}add/" class="addlink">{% trans 'Add' %}</a></td>
{% else %}
<td>&nbsp;</td>
{% endif %}
{% if model.perms.change %}
<td><a href="{{ model.admin_url }}" class="changelink">{% trans 'Change' %}</a></td>
{% else %}
<td>&nbsp;</td>
{% endif %}
</tr>
{% endfor %}
</table>
<h2>Convênios</h2>
<h3>Convênios com as Casas Legislativas</h3>
<p class="align-center">
<img src="{{ convenios.url }}" class="chart" />
</p>
</div>
{% endfor %}
{% else %}
<p>{% trans "You don't have permission to edit anything." %}</p>
{% endif %}
<div class="module">
<h2>Convênios</h2>
<h3>Casas Legislativas conveniadas por região</h3>
<p class="align-center">
<img src="{{ regioes.url }}" class="chart" />
</p>
</div>
</div>
{% endblock %}

Loading…
Cancel
Save