Browse Source

Unifica relatório de convênios

pull/159/head
Sesostris Vieira 2 years ago
parent
commit
86ba8ab9bf
  1. 69
      sigi/apps/convenios/admin.py
  2. 22
      sigi/apps/convenios/templates/convenios/convenios_report.html

69
sigi/apps/convenios/admin.py

@ -201,8 +201,6 @@ class ConvenioAdmin(CartExportReportMixin, admin.ModelAdmin):
resource_class = ConvenioExportResourse
reports = [
"report_convenios",
"report_convenios_camaras",
"report_convenios_assembleia",
]
def get_queryset(self, request):
@ -253,7 +251,11 @@ class ConvenioAdmin(CartExportReportMixin, admin.ModelAdmin):
def report_convenios(self, request):
context = {
"convenios": self.get_queryset(request),
"convenios": self.get_queryset(request).order_by(
"casa_legislativa__tipo",
"casa_legislativa__municipio__uf__sigla",
"data_retorno_assinatura",
),
"title": _("Relatório de convenios"),
}
return WeasyTemplateResponse(
@ -266,67 +268,6 @@ class ConvenioAdmin(CartExportReportMixin, admin.ModelAdmin):
report_convenios.title = _("Relatório de convênios")
def report_convenios_camaras(self, request):
context = {
"convenios": self.get_queryset(request).filter(
casa_legislativa__tipo__sigla="CM"
),
"title": _("Relatório de convenios de camaras municipais"),
}
return WeasyTemplateResponse(
filename="relatorio_convenios.pdf",
request=request,
template="convenios/convenios_report.html",
context=context,
content_type="application/pdf",
)
report_convenios_camaras.title = _(
"Relatório de convênios de camaras municipais"
)
def report_convenios_assembleia(self, request):
context = {
"convenios": self.get_queryset(request).filter(
casa_legislativa__tipo__sigla="AL"
),
"title": _("Relatório de convenios de assembleias legislativas"),
}
return WeasyTemplateResponse(
filename="relatorio_convenios.pdf",
request=request,
template="convenios/convenios_report.html",
context=context,
content_type="application/pdf",
)
report_convenios_assembleia.title = _(
"Relatório de convênios de assembleias legislativas"
)
# def relatorio(self, request, queryset):
# # queryset.order_by('casa_legislativa__municipio__uf')
# response = HttpResponse(content_type='application/pdf')
# report = ConvenioReport(queryset=queryset)
# report.generate_by(PDFGenerator, filename=response)
# return response
# relatorio.short_description = _('Exportar convênios selecionados para PDF')
# def adicionar_convenios(self, request, queryset):
# if 'carrinho_convenios' in request.session:
# q1 = len(request.session['carrinho_convenios'])
# else:
# q1 = 0
# adicionar_convenios_carrinho(request, queryset=queryset)
# q2 = len(request.session['carrinho_convenios'])
# quant = q2 - q1
# if quant:
# self.message_user(request, str(q2 - q1) + _(" Convênios adicionados no carrinho"))
# else:
# self.message_user(request, _("Os Convênios selecionados já foram adicionadas anteriormente"))
# return HttpResponseRedirect('.')
# adicionar_convenios.short_description = _("Armazenar convênios no carrinho para exportar")
def get_actions(self, request):
actions = super(ConvenioAdmin, self).get_actions(request)
if "delete_selected" in actions:

22
sigi/apps/convenios/templates/convenios/convenios_report.html

@ -7,31 +7,33 @@
<table repeat="1">
<thead>
<tr>
<th style="width: 10%;">{% trans 'UF' %}</th>
<th style="width: 25%;">{% trans 'Orgão' %}</th>
<th style="width: 20%;">{% trans 'Municipio' %}</th>
<th style="width: 10%;">{% trans 'UF' %}</th>
<th style="width: 12%;">{% trans 'Número do Convênio' %}</th>
<th style="width: 8%;">{% trans 'Projeto' %}</th>
<th style="width: 15%;">{% trans 'Data do Convênio' %}</th>
<th style="width: 15%;">{% trans 'Data de Publicação' %}</th>
<th style="width: 25%;">{% trans 'Orgão' %}</th>
</tr>
</thead>
{% for convenio in convenios %}
{% ifchanged convenio.municipio.uf %}
<tr class="title_row"><td colspan="8"><h1>{{ convenio.casa.municipio.uf }}</h1></td></tr>
{% ifchanged convenio.casa_legislativa.tipo %}
<tr class="title_row">
<td colspan="8">
<h1>{{ convenio.casa_legislativa.tipo }}</h1>
</td>
</tr>
{% endifchanged %}
<tr>
<td>{{ convenio.casa_legislativa.municipio.uf.sigla }}</td>
<td>{{ convenio.casa_legislativa.nome }}</td>
<td>{{ convenio.casa_legislativa.municipio.nome }}</td>
<td>{{ convenio.casa_legislativa.municipio.uf.sigla }}</td>
<td>{{ convenio.num_convenio }}</td>
<td>{{ convenio.projeto }}</td>
<td>{{ convenio.data_retorno_assinatura}}</td>
<td>{{ convenio.data_pub_diario }}</td>
<td>{{ convenio.casa_legislativa.nome }}</td>
<td>{{ convenio.data_retorno_assinatura|date:"SHORT_DATE_FORMAT" }}</td>
<td>{{ convenio.data_pub_diario|date:"SHORT_DATE_FORMAT" }}</td>
</tr>
{% endfor %}
</table>
<h3>Número de Convênios:

Loading…
Cancel
Save