Browse Source

Melhorias no mapa para permitir embed

pull/163/head
Sesostris Vieira 2 years ago
parent
commit
895e78feaa
  1. 5
      sigi/apps/convenios/admin.py
  2. 15
      sigi/apps/convenios/models.py
  3. 79
      sigi/apps/home/static/home/css/openmap.css
  4. 303
      sigi/apps/home/templates/home/mapfilter.html
  5. 29
      sigi/apps/home/templates/home/openmap.html
  6. 68
      sigi/apps/home/templates/home/openmapdetail.html
  7. 15
      sigi/apps/home/views.py
  8. 4
      sigi/apps/servicos/urls.py
  9. 15
      sigi/apps/servicos/views.py

5
sigi/apps/convenios/admin.py

@ -256,10 +256,7 @@ class ConvenioAdmin(ReturnMixin, CartExportReportMixin, admin.ModelAdmin):
if not obj.id_contrato_gescon:
return ""
return mark_safe(
f"<a href='https://adm.senado.gov.br/gestao-contratos/api/"
f"contratos/buscaTexto/{obj.id_contrato_gescon}'>"
f"https://adm.senado.gov.br/gestao-contratos/api/"
f"{obj.id_contrato_gescon}</a>"
f"<a href='{obj.get_url_gescon()}'>{obj.id_contrato_gescon}</a>"
)
link_gescon.short_description = _("Download MINUTA ASSINADA do Gescon")

15
sigi/apps/convenios/models.py

@ -374,6 +374,21 @@ class Convenio(models.Model):
else:
return "<i class='material-icons'>visibility_off</i>"
def get_url_gescon(self):
if not self.id_contrato_gescon:
return ""
return (
"https://adm.senado.gov.br/gestao-contratos/api/contratos"
f"/buscaTexto/{self.id_contrato_gescon}"
)
def get_url_minuta(self):
if self.id_contrato_gescon:
return self.get_link_gescon()
if self.anexo_set.exists():
return self.anexo_set.first().arquivo.url
return ""
def save(self, *args, **kwargs):
self.conveniada = self.data_retorno_assinatura is not None
self.equipada = self.data_termo_aceite is not None

79
sigi/apps/home/static/home/css/openmap.css

@ -7,17 +7,15 @@ html,
}
#content {
height: 91%;
height: calc(100% - 60px);
}
.filterwrap {
background-color: rgba(255, 255, 255, 0.5);
border-radius: 5px;
margin: 12px;
max-height: 80%;
position: absolute;
top: 0;
left: 0;
z-index: 314159;
height: 100%;
max-height: 100%;
overflow-y: auto;
}
@ -53,6 +51,7 @@ html,
.search-result-item {
display: list-item;
list-style: none;
padding: 3px 3px 3px 20px;
font-weight: bold;
}
@ -67,4 +66,72 @@ li>a.clear-filters>i.material-icons {
color: var(--main-bg-color);
border-color: var(--main-bg-color);
margin: 0px 10px 0px 0px;
}
.map-bar {
width: calc(100% - 24px);
height: 45px;
border-radius: 5px;
background-image: linear-gradient(to right, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0));
position: absolute;
margin: 12px 0 0 12px;
padding-left: 24px;
display: flex;
flex-direction: row;
flex-wrap: wrap;
z-index: 1000;
pointer-events: none;
}
.map-bar .inner {
padding-left: 12px;
pointer-events: auto;
}
#container {
display: block !important;
padding: 0 !important;
}
.search-text::placeholder {
color: var(--body-quiet-color);
}
.search-text::-ms-input-placeholder {
/* Microsoft Edge */
color: var(--body-quiet-color);
}
.search-text:-ms-input-placeholder {
/* Internet Explorer 10-11 */
color: var(--body-quiet-color);
}
.search-result {
background-color: rgba(255, 255, 255, 0.5);
}
.action-buttons {
display: flex;
align-items: center;
height: 45px;
}
.map-total-bar {
width: calc(100% - 24px);
border-radius: 5px;
background-image: linear-gradient(to right, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0));
position: absolute;
margin: 12px 0 0 12px;
padding-left: 24px;
display: flex;
flex-direction: row;
flex-wrap: wrap;
z-index: 1000;
pointer-events: none;
bottom: 1px;
}
.embed-map-content {
height: 100% !important;
}

303
sigi/apps/home/templates/home/mapfilter.html

@ -1,189 +1,124 @@
{% load i18n material %}
{% load i18n %}
<div class="scroll-pane">
{% if not mobile %}
<i class="material-icons minimize nav-bar" aria-hidden="true" title="{% trans 'Minimize' %}">close</i>
{% endif %}
<form id="filterForm" action="" method="get">
{{ csrftoken }}
</form>
<ul class="collapsible">
<li>
<div class="card">
<div class="card-image">
{% if 'profile/user_picture.html'|template_exists %}
{% include 'profile/user_picture.html' %}
{% else %}
{% include 'material/admin/user_picture.html' %}
{% endif %}
<div id="filter-modal" class="modal">
<div class="modal-content">
<h6 class="left">Filtrar por</h6>
<a href="#!" class="modal-close right"><i class="material-icons">close</i></a>
<form id="filterForm" action="" method="get">{{ csrftoken }}
<div class="row">
<div class="col s12">
<ul class="tabs">
<li class="tab"><a class="active" href="#tab_tipo_orgao">{% trans "Órgão" %}</a></li>
<li class="tab"><a href="#tab_tipo_servico">{% trans "Serviço" %}</a></li>
<li class="tab"><a href="#tab_tipo_convenio">{% trans "Convênio" %}</a></li>
<li class="tab"><a href="#tab_regiao_uf">{% trans "Região/estados" %}</a></li>
<li class="tab"><a href="#tab_gerente">{% trans "Gerente" %}</a></li>
</ul>
</div>
</div>
</li>
<li>
<div class="card" id="filterbox">
<div class="card-content">
<form id="searchform" class="form-inline ui-front">
<div class="input-field">
<i class="material-icons prefix">search</i>
<input type="text" class="search-text" placeholder="{% trans "Procurar" %}"
aria-label="{% trans "Procurar" %}" data-source="{% url 'openmapsearch' %}" data-param="q">
<div class="search-result hide" data-item-click="map_fly_to"></div>
</form>
<div id="tab_tipo_orgao" class="col s12">
{% for o in tipos_orgao %}
<p>
<label>
<input type="checkbox" form="filterForm" id="tipo_orgao_{{ o.sigla }}" name="tipo_orgao" value="{{ o.sigla }}"{% if o.sigla in pre_tipos_orgao or not pre_tipos_orgao %} checked{% endif %} />
<span>{{ o.nome }}</span>
</label>
</p>
{% endfor %}
</div>
<div id="tab_tipo_servico" class="col s12">
<p>
<label>
<input type="checkbox" form="filterForm" id="tipo_servico_ignore" name="ignore_tipo_servico" value="ignore" data-controls="tipo_servico"{% if 'ignore' in pre_tipos_servico %} checked{% endif %} />
<span>{% trans "Ignorar" %}
</label>
</p>
<p>
<label>
<input type="checkbox" form="filterForm" id="tipo_servico_none" name="tipo_servico" value="none"{% if 'none' in pre_tipos_servico %} checked{% endif %} />
<span>{% trans "Nenhum serviço" %}</span>
</label>
</p>
{% for s in tipos_servico %}
<p>
<label>
<input type="checkbox" form="filterForm" id="tipo_servico_{{ s.sigla }}" name="tipo_servico"
value="{{ s.sigla }}"{% if s.sigla in pre_tipos_servico or not pre_tipos_servico %} checked{% endif %} />
<span>{{ s.nome }}</span>
</label>
</p>
{% endfor %}
</div>
<div id="tab_tipo_convenio" class="col s12">
<p>
<label>
<input type="checkbox" form="filterForm" id="tipo_convenio_ignore" name="ignore_tipo_convenio" value="ignore"
data-controls="tipo_convenio"{% if 'ignore' in pre_tipos_convenio %} checked{% endif %} />
<span>{% trans "Ignorar" %}</span>
</label>
</p>
<p>
<label>
<input type="checkbox" form="filterForm" id="tipo_convenio_none" name="tipo_convenio" value="none"{% if "none" in pre_tipos_convenio %} checked{% endif %} />
<span>{% trans "Sem convênio" %}</span>
</label>
</p>
{% for c in tipos_convenio %}
<p>
<label>
<input type="checkbox" form="filterForm" id="tipo_convenio_{{ c.sigla }}" name="tipo_convenio"
value="{{ c.sigla }}"{% if c.sigla in pre_tipos_convenio or not pre_tipos_convenio %} checked{% endif %}/>
<span>{{ c.nome }}</span>
</label>
</p>
{% endfor %}
</div>
<div id="tab_regiao_uf" class="col s12">
{% for s, n, ufs in regioes %}
<p>
<label>
<input type="checkbox" form="filterForm" id="regiao_{{ s }}" name="regiao" value="{{ s }}" />
<span>{{ n }}</span>
</label>
</p>
<div class="region-ufs">
{% for uf in ufs %}
<p>
<label>
<input type="checkbox" form="filterForm" id="uf_{{ uf.sigla }}" name="uf" value="{{ uf.sigla }}"
data-regiao="{{ s }}" {% if uf.sigla in pre_ufs %} checked{% endif %}/>
<span>{{ uf.nome }}</span>
</label>
</p>
{% endfor %}
</div>
{% endfor %}
</div>
<div id="tab_gerente" class="col s12">
<p>
<label>
<input type="checkbox" form="filterForm" id="gerente_ignore" name="gerente_ignore" value="ignore"
data-controls="gerente"{% if "ignore" in pre_gerentes %} checked{% endif %} />
<span>{% trans "Ignorar" %}</span>
</label>
</p>
<p>
<label>
<input type="checkbox" form="filterForm" id="gerente_none" name="gerente" value="none" {% if "none" in pre_gerentes %} checked{% endif %}/>
<span>{% trans "Sem gerente" %}</span>
</label>
</p>
{% for g in gerentes %}
<p>
<label>
<input type="checkbox" form="filterForm" id="gerente_{{ g.id|stringformat:"s" }}" name="gerente"
value="{{ g.id|stringformat:"s" }}" {% if g.id|stringformat:"s" in pre_gerentes or not pre_gerentes%} checked{% endif %}/>
<span>{{ g.nome_completo }}</span>
</label>
</p>
{% endfor %}
</div>
</div>
</div>
<small><strong>Total de Órgãos selecionados: </strong><span id="totalOrgao">-</span></small>
<a href="#" class="right center-map" title="{% trans 'Centralizar o mapa' %}"><i class="material-icons">my_location</i></a>
<a href="#" class="right clear-filters" title="{% trans 'Remover todos os filtros' %}"><i class="material-icons">clear_all</i></a>
</li>
<li>
<div class="collapsible-header">{% trans "Por Tipo de órgão" %}</div>
<div class="collapsible-body">
{% for o in tipos_orgao %}
<p>
<label>
<input type="checkbox" form="filterForm" id="tipo_orgao_{{ o.sigla }}" name="tipo_orgao" value="{{ o.sigla }}"{% if o.sigla in pre_tipos_orgao or not pre_tipos_orgao %} checked{% endif %} />
<span>{{ o.nome }}</span>
</label>
</p>
{% endfor %}
</form>
</div>
</li>
<li>
<div class="collapsible-header">{% trans "Por Tipo de serviço" %}</div>
<div class="collapsible-body">
<p>
<label>
<input type="checkbox" form="filterForm" id="tipo_servico_ignore" name="ignore_tipo_servico" value="ignore" data-controls="tipo_servico"{% if 'ignore' in pre_tipos_servico %} checked{% endif %} />
<span>{% trans "Ignorar" %}
</label>
</p>
<p>
<label>
<input type="checkbox" form="filterForm" id="tipo_servico_none" name="tipo_servico" value="none"{% if 'none' in pre_tipos_servico %} checked{% endif %} />
<span>{% trans "Nenhum serviço" %}</span>
</label>
</p>
{% for s in tipos_servico %}
<p>
<label>
<input type="checkbox" form="filterForm" id="tipo_servico_{{ s.sigla }}" name="tipo_servico"
value="{{ s.sigla }}"{% if s.sigla in pre_tipos_servico or not pre_tipos_servico %} checked{% endif %} />
<span>{{ s.nome }}</span>
</label>
</p>
{% endfor %}
</div>
</li>
<li>
<div class="collapsible-header">{% trans "Por convênio" %}</div>
<div class="collapsible-body">
<p>
<label>
<input type="checkbox" form="filterForm" id="tipo_convenio_ignore" name="ignore_tipo_convenio" value="ignore"
data-controls="tipo_convenio"{% if 'ignore' in pre_tipos_convenio %} checked{% endif %} />
<span>{% trans "Ignorar" %}</span>
</label>
</p>
<p>
<label>
<input type="checkbox" form="filterForm" id="tipo_convenio_none" name="tipo_convenio" value="none"{% if "none" in pre_tipos_convenio %} checked{% endif %} />
<span>{% trans "Sem convênio" %}</span>
</label>
</p>
{% for c in tipos_convenio %}
<p>
<label>
<input type="checkbox" form="filterForm" id="tipo_convenio_{{ c.sigla }}" name="tipo_convenio"
value="{{ c.sigla }}"{% if c.sigla in pre_tipos_convenio or not pre_tipos_convenio %} checked{% endif %}/>
<span>{{ c.nome }}</span>
</label>
</p>
{% endfor %}
</div>
</li>
<li>
<div class="collapsible-header">{% trans "Por região/estado" %}</div>
<div class="collapsible-body">
{% for s, n, ufs in regioes %}
<p>
<label>
<input type="checkbox" form="filterForm" id="regiao_{{ s }}" name="regiao" value="{{ s }}" />
<span>{{ n }}</span>
</label>
</p>
<div class="region-ufs">
{% for uf in ufs %}
<p>
<label>
<input type="checkbox" form="filterForm" id="uf_{{ uf.sigla }}" name="uf" value="{{ uf.sigla }}"
data-regiao="{{ s }}" {% if uf.sigla in pre_ufs %} checked{% endif %}/>
<span>{{ uf.nome }}</span>
</label>
</p>
{% endfor %}
</div>
{% endfor %}
</div>
</li>
<li>
<div class="collapsible-header">{% trans "Por gerente Interlegis" %}</div>
<div class="collapsible-body">
<p>
<label>
<input type="checkbox" form="filterForm" id="gerente_ignore" name="gerente_ignore" value="ignore"
data-controls="gerente"{% if "ignore" in pre_gerentes %} checked{% endif %} />
<span>{% trans "Ignorar" %}</span>
</label>
</p>
<p>
<label>
<input type="checkbox" form="filterForm" id="gerente_none" name="gerente" value="none" {% if "none" in pre_gerentes %} checked{% endif %}/>
<span>{% trans "Sem gerente" %}</span>
</label>
</p>
{% for g in gerentes %}
<p>
<label>
<input type="checkbox" form="filterForm" id="gerente_{{ g.id|stringformat:"s" }}" name="gerente"
value="{{ g.id|stringformat:"s" }}" {% if g.id|stringformat:"s" in pre_gerentes or not pre_gerentes%} checked{% endif %}/>
<span>{{ g.nome_completo }}</span>
</label>
</p>
{% endfor %}
</div>
</li>
{% if not user.is_anonymous %}
<li>
<div class="collapsible-header">{% trans "Exportação de dados" %}</div>
<div class="collapsible-body">
<button class="waves-effect waves-light btn-small btn-flat" name="reptype" value="lista" type="submit"
form="filterForm">
<i class="material-icons">picture_as_pdf</i>
Listagem
</button>
<button class="waves-effect waves-light btn-small btn-flat" name="reptype" value="exporta" type="submit"
form="filterForm">
Exportação completa
</button>
<button class="waves-effect waves-light btn-small btn-flat" name="reptype" value="exporta_servico" type="submit"
form="filterForm">
Exportar serviços
</button>
<button class="waves-effect waves-light btn-small btn-flat" name="reptype" value="exporta_convenio" type="submit"
form="filterForm">
Exportar convênios
</button>
<button class="waves-effect waves-light btn-small btn-flat" name="reptype" value="exporta_contato" type="submit"
form="filterForm">
Exportar contatos
</button>
</div>
</li>
{% endif %}
</ul>
</div>
</div>

29
sigi/apps/home/templates/home/openmap.html

@ -54,17 +54,28 @@
{% endblock %}
{% block side_nav %}
{% if not nav_bar_minimized %}
<div id="side-bar" class="hide-on-med-and-down">
{% include 'home/mapfilter.html' %}
</div>
{% endif %}
<div id="mobile-demo" class="sidenav">
{% include 'home/mapfilter.html' with mobile=True %}
</div>
{% endblock %}
{% block coltype %}{{ block.super }}{% if is_popup %} embed-map-content{% endif %}
{% endblock %}
{% block content %}
<div id="map-bar" class="map-bar">
<div class="inner action-buttons">
<a class="modal-trigger" href="#filter-modal" title="{% trans "Filtrar dados" %}"><i class="material-icons">filter_list</i></a>
<a href="#" class="center-map" title="{% trans 'Centralizar o mapa' %}"><i class="material-icons">my_location</i></a>
<a href="#" class="clear-filters" title="{% trans 'Remover todos os filtros' %}"><i class="material-icons">clear_all</i></a>
</div>
<div class="inner">
<form id="searchform" class="form-inline ui-front">
<input type="text" class="search-text" placeholder="{% trans "Procurar" %}" aria-label="{% trans "Procurar" %}" data-source="{% url 'openmapsearch' %}" data-param="q">
<div class="search-result hide" data-item-click="map_fly_to"></div>
</form>
</div>
</div>
<div class="map-total-bar">
<small><strong>Total de Órgãos selecionados: </strong><span id="totalOrgao">-</span></small>
</div>
{% include "home/mapfilter.html" %}
<div id="map">
<!-- open street map -->
</div>
@ -82,6 +93,8 @@
var options = { color: 'blue', fillColor: 'red', fillOpacity: 0.4, radius: 500 };
var unfiltred_options = { color: 'red', fillColor: 'red', fillOpacity: 0, radius: 1000 };
$(document).ready(function () {
M.Modal.init($('.modal'));
M.Tabs.init($('.tabs'));
$("input[type=checkbox]").change(filtra);
var base_layers = {

68
sigi/apps/home/templates/home/openmapdetail.html

@ -1,23 +1,47 @@
<div class="card">
<div class="card-header">
<strong>{{ orgao.nome }}</strong> <a href="{% url "admin:casas_orgao_change" orgao.id %}" title="Editar" target="_blank"><span class="glyphicon glyphicon-edit"></span></a>
</div>
<div class="card-body">
<table class="table-condensed">
<tr><th>CNPJ</th><td>{{ orgao.cnpj }}</td></tr>
{% if orgao.data_instalacao %}<tr><th>Data de instalação</th><td>{{ orgao.data_instalacao }}</td></tr>{% endif %}
<tr><th>Endereço</th><td><address>{{ orgao.logradouro }}, {{ orgao.bairro }}, {{ orgao.municipio.nome }}, {{ orgao.municipio.uf.sigla }}, CEP: {{ orgao.cep }}</address></td></tr>
{% if orgao.telefones.all %}<tr><th>Telefones</th><td>{% for telefone in orgao.telefones.all %}<a href="tel:{{ telefone.numero }}">{{ telefone.numero }}</a>{% if not forloop.last %}, {% endif %}{% endfor %}</td></tr>{% endif %}
{% if orgao.email %}<tr><th>E-mail</th><td><a href="mailto:{{ orgao.email }}">{{ orgao.email }}</a></td></tr>{% endif %}
{% if orgao.convenio_set.all %}
<tr><th>Convênios</th><td>{% for c in orgao.convenio_set.all %}<a href="{% url 'admin:convenios_convenio_change' c.id %}" target="_blank">{{ c }}</a>{% if not forloop.last %}, {% endif %}{% endfor %}</td></tr>
<table class="striped">
<tr>
<th colspan="2">
{% if user.is_staff %}
{% url "admin:casas_orgao_change" orgao.id as orgao_url %}
{% else %}
{% url "servicos_casas_atendidas" orgao.id as orgao_url %}
{% endif %}
{% if orgao.servico_set.all %}
<tr><th>Serviços</th><td>{% for s in orgao.servico_set.all %}{% if s.url %}<a href="{{ s.url }}" target="_blank">{{ s }}</a>{% else %}{{ s }}{% endif %}{% if not forloop.last %}, {% endif %}{% endfor %}</td></tr>
{% endif %}
{% if orgao.gerentes_interlegis.all %}
<tr><th>Gerentes</th><td>{% for g in orgao.gerentes_interlegis.all %}{{ g.nome_completo }}{% if not forloop.last %}, {% endif %} {% endfor %}</td></tr>
{% endif %}
</table>
</div>
</div>
<a href="{{ orgao_url }}" target="_blank">
{{ orgao }}
</a>
</th>
</tr>
<tr><th>Endereço</th><td><address>{{ orgao.logradouro }}, {{ orgao.bairro }}, {{ orgao.municipio.nome }}, {{ orgao.municipio.uf.sigla }}, CEP: {{ orgao.cep }}</address></td></tr>
{% if telefones %}
<tr>
<th>Telefones</th>
<td>
{% for telefone in telefones %}
<a href="tel:{{ telefone }}">{{ telefone }}</a>
{% if not forloop.last %}, {% endif %}
{% endfor %}
</td>
</tr>
{% endif %}
{% if orgao.email %}<tr><th>E-mail</th><td><a href="mailto:{{ orgao.email }}">{{ orgao.email }}</a></td></tr>{% endif %}
{% if orgao.convenio_set.all %}
<tr>
<th>Convênios</th>
<td>
{% for c in orgao.convenio_set.all %}
{% if user.is_staff %}
<a href="{% url 'admin:convenios_convenio_change' c.id %}" target="_blank">
{{ c.projeto.sigla }} ({{ c.get_status }})
</a>
{% else %}
{{ c.projeto.sigla }} ({{ c.get_status }})
{% endif %}
{% if not forloop.last %}, {% endif %}
{% endfor %}
</td>
</tr>
{% endif %}
{% if orgao.servico_set.all %}
<tr><th>Serviços</th><td>{% for s in servicos.all %}{% if s.url %}<a href="{{ s.url }}" target="_blank">{{ s }}</a>{% else %}{{ s }}{% endif %}{% if not forloop.last %}, {% endif %}{% endfor %}</td></tr>
{% endif %}
</table>

15
sigi/apps/home/views.py

@ -157,9 +157,10 @@ class HomeView(LoginRequiredMixin, TemplateView):
################################################################################
@xframe_options_exempt
def openmap(request):
reptype = request.GET.get("reptype", None)
context = {}
context = {"is_popup": bool(int(request.GET.get("embed", 0)))}
if reptype is None:
context["tipos_orgao"] = TipoOrgao.objects.filter(legislativo=True)
@ -330,7 +331,17 @@ def openmapdata(request):
def openmapdetail(request, orgao_id):
orgao = get_object_or_404(Orgao, id=orgao_id)
return render(request, "home/openmapdetail.html", {"orgao": orgao})
servicos = orgao.servico_set.filter(data_desativacao=None)
telefones = {
t.numero.replace(" ", "") for t in orgao.telefones.exclude(numero="")
}
telefones.add(orgao.telefone_geral.replace(" ", ""))
telefones.add(orgao.telefone.replace(" ", ""))
return render(
request,
"home/openmapdetail.html",
{"orgao": orgao, "servicos": servicos, "telefones": telefones},
)
def openmapsearch(request):

4
sigi/apps/servicos/urls.py

@ -6,10 +6,10 @@ urlpatterns = [
"casasatendidas/",
views.CasasAtendidasListView.as_view(),
name="servicos_casas_atendidas",
kwargs={"sigla_uf": "_all_"},
kwargs={"param": "_all_"},
),
path(
"casasatendidas/<str:sigla_uf>/",
"casasatendidas/<str:param>/",
views.CasasAtendidasListView.as_view(),
name="servicos_casas_atendidas",
),

15
sigi/apps/servicos/views.py

@ -45,8 +45,9 @@ class CasasAtendidasListView(ListView):
paginate_by = 100
def get_queryset(self):
sigla = self.kwargs["sigla_uf"]
param = self.kwargs["param"]
search_param = self.request.GET.get("search", None)
queryset = super().get_queryset()
queryset = (
queryset.filter(
@ -72,15 +73,17 @@ class CasasAtendidasListView(ListView):
for t in search_param.split()
]
queryset = queryset.filter(*filter)
if sigla != "_all_":
if param.isdigit():
queryset = queryset.filter(casa_legislativa__id=param)
elif param != "_all_":
queryset = queryset.filter(
casa_legislativa__municipio__uf__sigla=sigla
casa_legislativa__municipio__uf__sigla=param
)
return queryset
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
sigla = self.kwargs["sigla_uf"]
param = self.kwargs["param"]
context["tot_orgaos"] = (
self.get_queryset()
.order_by()
@ -95,8 +98,8 @@ class CasasAtendidasListView(ListView):
for r, regiao in UnidadeFederativa.REGIAO_CHOICES
]
context["search_param"] = self.request.GET.get("search", None)
if sigla != "_all_":
context["uf"] = UnidadeFederativa.objects.get(sigla=sigla)
if param != "_all_" and not param.isdigit():
context["uf"] = UnidadeFederativa.objects.get(sigla=param)
return context
def render_to_response(self, context, **response_kwargs):

Loading…
Cancel
Save