diff --git a/sigi/apps/servicos/views.py b/sigi/apps/servicos/views.py
new file mode 100644
index 0000000..73129f0
--- /dev/null
+++ b/sigi/apps/servicos/views.py
@@ -0,0 +1,28 @@
+# -*- coding: utf-8 -*-
+from django.http import HttpResponse
+from django.utils import simplejson
+from django.db.models import Q
+from sigi.apps.servicos.models import CasaAtendida
+
+def municipios_atendidos(self, servico):
+ municipios = []
+ servico = servico.upper()
+
+ query = Q()
+
+ if servico != 'ALL':
+ for sigla in servico.split('_'):
+ query = query | Q(tipo_servico__sigla=sigla)
+
+ query = Q(data_desativacao=None) & query
+
+ for casa in CasaAtendida.objects.all():
+ if casa.servico_set.filter(query).exists():
+ m = casa.municipio
+ municipio = {'nome': casa.nome + ', ' + m.uf.sigla,
+ 'lat': str(m.latitude),
+ 'lng': str(m.longitude),
+ 'servicos': "
- " + "
- ".join([s.tipo_servico.nome for s in casa.servico_set.filter(query)]) + "
",}
+ municipios.append(municipio)
+
+ return HttpResponse(simplejson.dumps(municipios), mimetype="application/json")
\ No newline at end of file
diff --git a/sigi/templates/servicos/mapa.html b/sigi/templates/servicos/mapa.html
new file mode 100644
index 0000000..71ed2dd
--- /dev/null
+++ b/sigi/templates/servicos/mapa.html
@@ -0,0 +1,61 @@
+{% extends "admin/index.html" %}
+{% load adminmedia %}
+
+{% block title %}SIGI{% endblock %}
+
+{% block extrahead %}
+ {{ block.super }}
+
+
+
+
+
+{% endblock %}
+
+{% block content %}
+{% comment %}
+
+
+
+{% endcomment %}
+
+{% endblock %}
diff --git a/sigi/templates/snippets/modules/charts-convenios.html b/sigi/templates/snippets/modules/charts-convenios.html
index 26460c3..3794c10 100644
--- a/sigi/templates/snippets/modules/charts-convenios.html
+++ b/sigi/templates/snippets/modules/charts-convenios.html
@@ -81,6 +81,7 @@
{% endif %}
{% endfor %}
+ Ver mapa
diff --git a/sigi/urls.py b/sigi/urls.py
index 039f2c5..0a6cd2c 100644
--- a/sigi/urls.py
+++ b/sigi/urls.py
@@ -1,8 +1,9 @@
#-*- coding:utf-8 -*-
from django.conf import settings
from django.conf.urls.defaults import patterns, include, url
-from django.views.generic.simple import redirect_to, direct_to_template
+from django.views.generic.simple import redirect_to, direct_to_template
import sites
+from sigi.apps.servicos.models import TipoServico
# register admin filters
import admin.filterspecs
@@ -90,6 +91,8 @@ urlpatterns = patterns(
(r'^sigi/api/diagnosticos/$',
'sigi.apps.diagnosticos.views.grafico_api'),
# Views dos serviços SEIT
+ (r'^sigi/servicos/mapa/(?P\w+)/$', direct_to_template, {'template': 'servicos/mapa.html', 'extra_context': {'servicos': TipoServico.objects.all()}}),
+ (r'^sigi/servicos/munatenjson/(?P\w+)/$', 'sigi.apps.servicos.views.municipios_atendidos'),
# (r'^sigi/servicos/listacasas/(?P\w+)',
# 'sigi.apps.servicos.views.casas_usam_servico'),
# automatic interface based on admin