Browse Source

Relatorio de casas sem convenio usando filtros

diagnosticos
Starlone (Estagiario) 15 years ago
parent
commit
202e5614a9
  1. 6
      sigi/apps/casas/reports.py
  2. 2
      sigi/apps/casas/templates/casas/change_list.html
  3. 12
      sigi/apps/casas/views.py

6
sigi/apps/casas/reports.py

@ -131,4 +131,8 @@ class CasasLegislativasReport(ReportDefault):
borders={'top': True}, borders={'top': True},
) )
) )
] ]
class CasasSemConvenioReport(CasasLegislativasReport):
title = u'Relatório de Casas Legislativas sem Convênio'

2
sigi/apps/casas/templates/casas/change_list.html

@ -5,7 +5,7 @@
{% if has_add_permission %} {% if has_add_permission %}
<ul class="object-tools"> <ul class="object-tools">
<li><a href="reports/{{query_str}}">Relatório</a> </li> <li><a href="reports/{{query_str}}">Relatório</a> </li>
<li><a href="casas_sem_convenio_report">Casas sem convênio</a> </li> <li><a href="casas_sem_convenio_report/{{query_str}}">Casas sem convênio</a> </li>
<li><a href="labels/{{ query_str }}">Gerar etiquetas</a></li> <li><a href="labels/{{ query_str }}">Gerar etiquetas</a></li>
<li> <li>
<a href="add/{% if is_popup %}?_popup=1{% endif %}" class="addlink"> <a href="add/{% if is_popup %}?_popup=1{% endif %}" class="addlink">

12
sigi/apps/casas/views.py

@ -3,6 +3,7 @@ from geraldo.generators import PDFGenerator
from sigi.apps.casas.models import CasaLegislativa from sigi.apps.casas.models import CasaLegislativa
from sigi.apps.casas.reports import CasasLegislativasLabels from sigi.apps.casas.reports import CasasLegislativasLabels
from sigi.apps.casas.reports import CasasLegislativasReport from sigi.apps.casas.reports import CasasLegislativasReport
from sigi.apps.casas.reports import CasasSemConvenioReport
def labels_report(request, id=None): def labels_report(request, id=None):
@ -43,8 +44,17 @@ def report(request, id=None):
def casas_sem_convenio_report(request): def casas_sem_convenio_report(request):
qs = CasaLegislativa.objects.filter(convenio=None).order_by('municipio__uf','nome') qs = CasaLegislativa.objects.filter(convenio=None).order_by('municipio__uf','nome')
if request.GET:
kwargs = {}
for k, v in request.GET.iteritems():
kwargs[str(k)] = v
qs = qs.filter(**kwargs)
if not qs:
return HttpResponseRedirect('../')
#qs.order_by('municipio__uf','nome')
response = HttpResponse(mimetype='application/pdf') response = HttpResponse(mimetype='application/pdf')
report = CasasLegislativasReport(queryset=qs) report = CasasSemConvenioReport(queryset=qs)
report.generate_by(PDFGenerator, filename=response) report.generate_by(PDFGenerator, filename=response)
return response return response

Loading…
Cancel
Save