Browse Source

Dividindo relatorio de convenio em relatorio de Camara Municipal e Assembleia Legislativa

diagnosticos
Starlone (Estagiario) 15 years ago
parent
commit
bb10c16737
  1. 3
      sigi/apps/convenios/templates/convenios/change_list.html
  2. 27
      sigi/apps/convenios/views.py
  3. 6
      sigi/urls.py

3
sigi/apps/convenios/templates/convenios/change_list.html

@ -4,7 +4,8 @@
{% block object-tools %} {% block object-tools %}
{% if has_add_permission %} {% if has_add_permission %}
<ul class="object-tools"> <ul class="object-tools">
<li><a href="reports/{{ query_str }}">Relatórios</a></li> <li><a href="reports_por_cm/{{ query_str }}">Relatórios por Câmara Municipal</a></li>
<li><a href="reports_por_al/{{ query_str }}">Relatórios por Assembléia Legislativa</a></li>
<li><a href="reportsRegiao/">Sumário Região</a></li> <li><a href="reportsRegiao/">Sumário Região</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">

27
sigi/apps/convenios/views.py

@ -5,8 +5,31 @@ from sigi.apps.convenios.reports import ConvenioReport, ConvenioReportRegiao
from sigi.apps.casas.models import CasaLegislativa from sigi.apps.casas.models import CasaLegislativa
def report(request, id=None): def report_por_cm(request, id=None):
qs = Convenio.objects.all().order_by('casa_legislativa__municipio__uf','casa_legislativa') qs = Convenio.objects.filter(casa_legislativa__tipo__sigla='CM').order_by('casa_legislativa__municipio__uf','casa_legislativa')
if id:
qs = qs.filter(pk=id)
elif request.GET: #Se tiver algum parametro de pesquisa
kwargs = {}
ids = 0
for k, v in request.GET.iteritems():
kwargs[str(k)] = v
if(str(k)=='ids'):
ids = 1
break
qs = qs.filter(**kwargs)
if ids:
query = 'id IN ('+ kwargs['ids'].__str__()+')'
qs = Convenio.objects.extra(where=[query])
if not qs:
return HttpResponseRedirect('../')
response = HttpResponse(mimetype='application/pdf')
report = ConvenioReport(queryset=qs)
report.generate_by(PDFGenerator, filename=response)
return response
def report_por_al(request, id=None):
qs = Convenio.objects.filter(casa_legislativa__tipo__sigla='AL').order_by('casa_legislativa__municipio__uf','casa_legislativa')
if id: if id:
qs = qs.filter(pk=id) qs = qs.filter(pk=id)
elif request.GET: #Se tiver algum parametro de pesquisa elif request.GET: #Se tiver algum parametro de pesquisa

6
sigi/urls.py

@ -18,8 +18,10 @@ urlpatterns = patterns(
'sigi.apps.casas.views.report'), 'sigi.apps.casas.views.report'),
(r'^casas/casalegislativa/casas_sem_convenio_report/', (r'^casas/casalegislativa/casas_sem_convenio_report/',
'sigi.apps.casas.views.casas_sem_convenio_report'), 'sigi.apps.casas.views.casas_sem_convenio_report'),
(r'^convenios/convenio/reports/', (r'^convenios/convenio/reports_por_cm/',
'sigi.apps.convenios.views.report'), 'sigi.apps.convenios.views.report_por_cm'),
(r'^convenios/convenio/reports_por_al/',
'sigi.apps.convenios.views.report_por_al'),
(r'^convenios/convenio/reportsRegiao/', (r'^convenios/convenio/reportsRegiao/',
'sigi.apps.convenios.views.reportRegiao'), 'sigi.apps.convenios.views.reportRegiao'),
# automatic interface based on admin # automatic interface based on admin

Loading…
Cancel
Save