From 86ba8ab9bfd2db8ea69f9239a8efb4d753d03f81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ses=C3=B3stris=20Vieira?= Date: Thu, 27 Oct 2022 14:05:37 -0300 Subject: [PATCH] =?UTF-8?q?Unifica=20relat=C3=B3rio=20de=20conv=C3=AAnios?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sigi/apps/convenios/admin.py | 69 ++----------------- .../templates/convenios/convenios_report.html | 36 +++++----- 2 files changed, 24 insertions(+), 81 deletions(-) diff --git a/sigi/apps/convenios/admin.py b/sigi/apps/convenios/admin.py index 5ad64b9..6190050 100644 --- a/sigi/apps/convenios/admin.py +++ b/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: diff --git a/sigi/apps/convenios/templates/convenios/convenios_report.html b/sigi/apps/convenios/templates/convenios/convenios_report.html index 1177639..c6db493 100644 --- a/sigi/apps/convenios/templates/convenios/convenios_report.html +++ b/sigi/apps/convenios/templates/convenios/convenios_report.html @@ -7,35 +7,37 @@ - + - - - - - + + + + + {% for convenio in convenios %} - {% ifchanged convenio.municipio.uf %} - - + {% ifchanged convenio.casa_legislativa.tipo %} + + + {% endifchanged %} + + - - - - - - + + + + - {% endfor %}
{% trans 'UF' %}{% trans 'Orgão' %} {% trans 'Municipio' %}{% trans 'Número do Convênio' %}{% trans 'Projeto' %}{% trans 'Data do Convênio' %}{% trans 'Data de Publicação' %}{% trans 'Orgão' %}{% trans 'UF' %}{% trans 'Número do Convênio' %}{% trans 'Projeto' %}{% trans 'Data do Convênio' %}{% trans 'Data de Publicação' %}

{{ convenio.casa.municipio.uf }}

+

{{ convenio.casa_legislativa.tipo }}

+
{{ convenio.casa_legislativa.nome }}{{ convenio.casa_legislativa.municipio.nome }} {{ convenio.casa_legislativa.municipio.uf.sigla }}{{ convenio.casa_legislativa.municipio.nome }}{{ convenio.num_convenio }}{{ convenio.projeto }}{{ convenio.data_retorno_assinatura}}{{ convenio.data_pub_diario }}{{ convenio.casa_legislativa.nome }}{{ convenio.num_convenio }}{{ convenio.projeto }}{{ convenio.data_retorno_assinatura|date:"SHORT_DATE_FORMAT" }}{{ convenio.data_pub_diario|date:"SHORT_DATE_FORMAT" }}

Número de Convênios: - {{ convenios|length }} + {{ convenios|length }}

{% endblock main_content %} \ No newline at end of file