Browse Source

sudindo relatorio de convenios

revisaoSidenav
Lude Ribeiro 3 years ago
parent
commit
2441ff4097
  1. 70
      sigi/apps/convenios/admin.py
  2. 41
      sigi/apps/convenios/templates/convenios/convenios_report.html
  3. 4
      templates/admin/base.html

70
sigi/apps/convenios/admin.py

@ -9,8 +9,9 @@ from sigi.apps.convenios.models import (Projeto, StatusConvenio,
Gescon) Gescon)
from sigi.apps.utils import queryset_ascii from sigi.apps.utils import queryset_ascii
from sigi.apps.servidores.models import Servidor from sigi.apps.servidores.models import Servidor
from sigi.apps.casas.admin import GerentesInterlegisFilter from sigi.apps.casas.admin import ConveniosInline, GerentesInterlegisFilter
from sigi.apps.utils.mixins import CartExportReportMixin, LabeledResourse from sigi.apps.utils.mixins import CartExportReportMixin, LabeledResourse
from django_weasyprint.views import WeasyTemplateResponse
class ConvenioExportResourse(LabeledResourse): class ConvenioExportResourse(LabeledResourse):
class Meta: class Meta:
@ -86,13 +87,15 @@ class ConvenioAdmin(CartExportReportMixin, admin.ModelAdmin):
resource_class = ConvenioExportResourse resource_class = ConvenioExportResourse
reports = [ reports = [
'report_convenios', 'report_convenios',
'report_convenios_data_aceite',
'report_convenios_camaras', 'report_convenios_camaras',
'report_convenios_camaras_data_aceite',
'report_convenios_assembleia', 'report_convenios_assembleia',
'report_convenios_assembleia_data_aceite',
] ]
def get_queryset(self, request):
queryset = super(ConvenioAdmin, self).get_queryset(request)
print (queryset)
return queryset
def get_uf(self, obj): def get_uf(self, obj):
return obj.casa_legislativa.municipio.uf.sigla return obj.casa_legislativa.municipio.uf.sigla
get_uf.short_description = _('UF') get_uf.short_description = _('UF')
@ -131,36 +134,49 @@ class ConvenioAdmin(CartExportReportMixin, admin.ModelAdmin):
link_gescon.short_description = _("Download MINUTA ASSINADA do Gescon") link_gescon.short_description = _("Download MINUTA ASSINADA do Gescon")
def report_convenios(self, request): def report_convenios(self, request):
return HttpResponseRedirect('../') context = {
report_convenios.title = _('Todos os convênios') 'convenios': self.get_queryset(request),
'title': _('Relatório de convenios'),
}
return WeasyTemplateResponse(
filename='relatorio_convenios.pdf',
request=request,
template="convenios/convenios_report.html",
context=context,
content_type='application/pdf',
)
report_convenios.title = _('Relatório de convênios')
def report_convenios_data_aceite(self, request):
return HttpResponseRedirect('../')
report_convenios_data_aceite.title = _(
'Todos os convênios com data aceite (equipada)'
)
def report_convenios_camaras(self, request): def report_convenios_camaras(self, request):
return HttpResponseRedirect('../') context = {
report_convenios_camaras.title = _('Convênios das Câmaras Municipais') 'convenios': self.get_queryset(request).filter(casa_legislativa__tipo__legislativo = False),
'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_camaras_data_aceite(self, request):
return HttpResponseRedirect('../')
report_convenios_camaras_data_aceite.title = _(
'Convênios das Câmaras Municipais com data aceite (equipada)'
)
def report_convenios_assembleia(self, request): def report_convenios_assembleia(self, request):
return HttpResponseRedirect('../') context = {
report_convenios_assembleia.title = _( 'convenios': self.get_queryset(request).filter(casa_legislativa__tipo__legislativo = True),
'Convênios das Assembléias Legislativas' '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 report_convenios_assembleia_data_aceite(self, request):
return HttpResponseRedirect('../')
report_convenios_assembleia_data_aceite.title = _(
'Convênios das Assembléias Legislativas com data aceite (equipada)'
)
# def relatorio(self, request, queryset): # def relatorio(self, request, queryset):
# # queryset.order_by('casa_legislativa__municipio__uf') # # queryset.order_by('casa_legislativa__municipio__uf')

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

@ -0,0 +1,41 @@
{% extends 'pdf/base_report.html' %}
{% load static i18n %}
{% block page_size %}A4 portrait{% endblock %}
{% block main_content %}
<table repeat="1">
<thead>
<tr>
<th style="width: 10%;">{% trans 'UF' %}</th>
<th style="width: 20%;">{% trans 'Municipio' %}</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>
{% endifchanged %}
<tr>
<td>{{ convenio.casa_legislativa.municipio.uf.sigla }}</td>
<td>{{ convenio.casa_legislativa.municipio.nome }}</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>
</tr>
{% endfor %}
</table>
<h3>Número de Convênios:
{{ convenios|length }}
</h3>
{% endblock main_content %}

4
templates/admin/base.html

@ -147,7 +147,7 @@
{% endif %} {% endif %}
<!-- Content --> <!-- Content -->
<div id="content" class="{% block coltype %}colM{% endblock %}"> {% comment %} <div id="content" class="{% block coltype %}colM{% endblock %}">
{% block content_title %}{% if title %}<h1>{{ title }}</h1>{% endif %}{% endblock %} {% block content_title %}{% if title %}<h1>{{ title }}</h1>{% endif %}{% endblock %}
@ -177,7 +177,7 @@
{% block content %}{{ content }}{% endblock %} {% block content %}{{ content }}{% endblock %}
{% block sidebar %}{% endblock %} {% block sidebar %}{% endblock %}
</div> </div> {% endcomment %}
<!-- END Content --> <!-- END Content -->
{% block footer %}<footer id="footer"></footer>{% endblock %} {% block footer %}<footer id="footer"></footer>{% endblock %}

Loading…
Cancel
Save