diff --git a/sigi/apps/convenios/templates/convenios/carrinho.html b/sigi/apps/convenios/templates/convenios/carrinho.html
index 6ffa7a6..620421d 100644
--- a/sigi/apps/convenios/templates/convenios/carrinho.html
+++ b/sigi/apps/convenios/templates/convenios/carrinho.html
@@ -59,7 +59,8 @@
+
{% endblock %}
\ No newline at end of file
diff --git a/sigi/apps/convenios/views.py b/sigi/apps/convenios/views.py
index c14a1de..ae6da8d 100644
--- a/sigi/apps/convenios/views.py
+++ b/sigi/apps/convenios/views.py
@@ -20,6 +20,8 @@ from django.conf import settings
import datetime
+import csv
+
def query_ordena(qs,o,ot):
list_display = ('num_convenio', 'casa_legislativa',
'data_adesao','data_retorno_assinatura','data_termo_aceite',
@@ -292,4 +294,44 @@ def report_regiao(request,regiao='NE'):
pisa.startViewer(response)
return response
+
+def export_csv(request):
+ response = HttpResponse(mimetype='text/csv')
+ response['Content-Disposition'] = 'attachment; filename=convenios.csv'
+
+ csv_writer = csv.writer(response)
+ convenios = carrinhoOrGet_for_qs(request)
+ if not convenios:
+ return HttpResponseRedirect('../')
+
+ if request.POST:
+ atributos = request.POST.getlist("itens_csv_selected")
+ atributos2 = [s.encode("utf-8") for s in atributos]
+ csv_writer.writerow(atributos2)
+
+ for convenio in convenios:
+ lista = []
+ for atributo in atributos:
+ if u"No. Processo" == atributo:
+ lista.append(convenio.num_processo_sf.encode("utf-8"))
+ elif u"No. Convênio" == atributo:
+ lista.append(convenio.num_convenio.encode("utf-8"))
+ elif u"Projeto" == atributo:
+ lista.append(convenio.projeto.nome.encode("utf-8"))
+ elif u"Casa Legislativa" == atributo:
+ lista.append(convenio.casa_legislativa.nome.encode("utf-8"))
+ elif u"Data de Adesão" == atributo:
+ lista.append(convenio.data_adesao.strftime("%d/%m/%Y").encode("utf-8"))
+ elif u"Data de Convênio" == atributo:
+ lista.append(convenio.data_retorno_assinatura.strftime("%d/%m/%Y").encode("utf-8"))
+ elif u"Data da Publicacao no D.O." == atributo:
+ lista.append(convenio.data_pub_diario.strftime("%d/%m/%Y").encode("utf-8"))
+ elif u"Data Equipada" == atributo:
+ lista.append(convenio.data_termo_aceite.strftime("%d/%m/%Y").encode("utf-8"))
+ else:
+ pass
+
+ csv_writer.writerow(lista)
+
+ return response
diff --git a/sigi/urls.py b/sigi/urls.py
index 3916f43..4edc811 100644
--- a/sigi/urls.py
+++ b/sigi/urls.py
@@ -48,7 +48,10 @@ urlpatterns = patterns(
'sigi.apps.convenios.views.visualizar_carrinho'),
#CSV Casa
(r'^casas/casalegislativa/csv/',
- 'sigi.apps.casas.views.export_csv'),
+ 'sigi.apps.casas.views.export_csv'),
+ #CSV Convenio
+ (r'^convenios/convenio/csv/',
+ 'sigi.apps.convenios.views.export_csv'),
# Resumo por região PDF
(r'^reportsRegiao/(?P\w+)',
'sigi.apps.convenios.views.report_regiao'),