Browse Source

Melhorias na listagem de Órgaos Atendidos. Gertiq #160529

pull/169/head
Sesóstris Vieira 1 year ago
parent
commit
81590282a7
  1. 48
      sigi/apps/servicos/templates/servicos/casas_atendidas.html
  2. 18
      sigi/apps/servicos/views.py

48
sigi/apps/servicos/templates/servicos/casas_atendidas.html

@ -5,6 +5,13 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.2/font/bootstrap-icons.css"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.2/font/bootstrap-icons.css">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<style type="text/css">
.card-title {
background-color: rgba(0,0,0,.03);
padding-left: 24px;
border-left: 5px solid #ee6e73;
}
</style>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<title>{% trans "Órgãos Legislativos atendidos pelo Interlegis" %}</title> <title>{% trans "Órgãos Legislativos atendidos pelo Interlegis" %}</title>
</head> </head>
@ -100,6 +107,7 @@
</div> </div>
<div class="card-body"> <div class="card-body">
{% if srv.casa_legislativa.convenio_set.all %} {% if srv.casa_legislativa.convenio_set.all %}
<h6 class="card-title">{% trans "Convênios" %}</h6>
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-sm"> <table class="table table-sm">
<tr> <tr>
@ -136,12 +144,43 @@
</table> </table>
</div> </div>
{% endif %} {% endif %}
{% if srv.casa_legislativa.oficinas %}
<h6 class="card-title">{% trans "Oficinas realizadas" %}</h6>
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-sm"> <table class="table table-sm">
<tr> <tr>
<th>{% trans "Tipo de serviço" %}</th> <th>{% trans "Período" %}</th>
<th>{% trans "Data de instalação" %}</th> <th>{% trans "Nome" %}</th>
<th>{% trans "URL de acesso" %}</th> <th>{% trans "Participantes" %}</th>
</tr>
{% for oficina in srv.casa_legislativa.oficinas %}
<tr>
<td>
{% blocktranslate with inicio=oficina.data_inicio|date:"SHORT_DATE_FORMAT" termino=oficina.data_termino|date:"SHORT_DATE_FORMAT" %}
{{ inicio }} a {{ termino}}
{% endblocktranslate %}
</td>
<td>{{ oficina.nome }}</td>
<td>{{ oficina.total_participantes|default:"-" }}</td>
</tr>
{% endfor %}
</table>
</div>
{% endif %}
<h6 class="card-title">{% trans "Serviços Interlegis" %}</h6>
<div class="table-responsive">
<table class="table table-sm">
<tr style="vertical-align: bottom;">
<th rowspan="2">{% trans "Tipo de serviço" %}</th>
<th rowspan="2">{% trans "Data de instalação" %}</th>
<th rowspan="2">{% trans "URL de acesso" %}</th>
<th colspan="2">{% trans "Última verificação" %}</th>
<th rowspan="2">{% trans "Última utilização" %}</th>
</tr>
<tr>
<th>{% trans "Data" %}
<th>{% trans "Resultado" %}</th>
</tr> </tr>
{% endifchanged %} {% endifchanged %}
<tr> <tr>
@ -154,6 +193,9 @@
<p>-</p> <p>-</p>
{% endif %} {% endif %}
</td> </td>
<td>{{ srv.data_verificacao|default:"-" }}</td>
<td>{{ srv.get_resultado_verificacao_display }}</td>
<td>{{ srv.data_ultimo_uso|default:"-" }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</table></div></div></div> </table></div></div></div>

18
sigi/apps/servicos/views.py

@ -1,5 +1,5 @@
import csv import csv
from django.db.models import Q from django.db.models import Q, Prefetch
from django.http import HttpResponse from django.http import HttpResponse
from django.shortcuts import render from django.shortcuts import render
from django.utils.translation import gettext as _ from django.utils.translation import gettext as _
@ -9,6 +9,7 @@ from import_export import resources
from import_export.fields import Field from import_export.fields import Field
from sigi.apps.casas.models import Orgao from sigi.apps.casas.models import Orgao
from sigi.apps.contatos.models import UnidadeFederativa from sigi.apps.contatos.models import UnidadeFederativa
from sigi.apps.eventos.models import Evento
from sigi.apps.servicos.models import Servico from sigi.apps.servicos.models import Servico
from sigi.apps.utils import to_ascii from sigi.apps.utils import to_ascii
@ -48,6 +49,12 @@ class CasasAtendidasListView(ListView):
param = self.kwargs["param"] param = self.kwargs["param"]
search_param = self.request.GET.get("search", None) search_param = self.request.GET.get("search", None)
oficinas_qs = (
Evento.objects.exclude(data_inicio=None)
.exclude(data_termino=None)
.filter(status=Evento.STATUS_REALIZADO)
)
queryset = super().get_queryset() queryset = super().get_queryset()
queryset = ( queryset = (
queryset.filter( queryset.filter(
@ -60,7 +67,14 @@ class CasasAtendidasListView(ListView):
"casa_legislativa__municipio__uf", "casa_legislativa__municipio__uf",
"casa_legislativa__tipo", "casa_legislativa__tipo",
) )
.prefetch_related("casa_legislativa__convenio_set") .prefetch_related(
"casa_legislativa__convenio_set",
Prefetch(
"casa_legislativa__evento_set",
oficinas_qs,
to_attr="oficinas",
),
)
.order_by( .order_by(
"casa_legislativa__municipio__uf__nome", "casa_legislativa__municipio__uf__nome",
"casa_legislativa__tipo__nome", "casa_legislativa__tipo__nome",

Loading…
Cancel
Save