|
|
@ -1,10 +1,11 @@ |
|
|
|
# -*- coding: utf-8 -*- |
|
|
|
from django.http import HttpResponse, HttpResponseRedirect |
|
|
|
from geraldo.generators import PDFGenerator |
|
|
|
from sigi.apps.casas.models import CasaLegislativa |
|
|
|
from sigi.apps.casas.reports import CasasLegislativasLabels |
|
|
|
from sigi.apps.casas.reports import CasasLegislativasReport |
|
|
|
from sigi.apps.casas.reports import CasasSemConvenioReport |
|
|
|
|
|
|
|
import csv |
|
|
|
|
|
|
|
def labels_report(request, id=None): |
|
|
|
""" TODO: adicionar suporte para resultado de pesquisa do admin. |
|
|
@ -58,3 +59,16 @@ def casas_sem_convenio_report(request): |
|
|
|
report = CasasSemConvenioReport(queryset=qs) |
|
|
|
report.generate_by(PDFGenerator, filename=response) |
|
|
|
return response |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def export_csv(request): |
|
|
|
response = HttpResponse(mimetype='text/csv') |
|
|
|
response['Content-Disposition'] = 'attachment; filename=casas.csv' |
|
|
|
|
|
|
|
csv_writer = csv.writer(response) |
|
|
|
casas = CasaLegislativa.objects.filter(municipio__uf__sigla=u'MG') |
|
|
|
for casa in casas: |
|
|
|
csv_writer.writerow([casa.nome.encode("utf-8"), casa.municipio.uf.sigla.encode("utf-8")]) |
|
|
|
|
|
|
|
return response |
|
|
|