From 895e78feaa9d8e30e0a38ab5c37fd23c30974eb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ses=C3=B3stris=20Vieira?= Date: Wed, 3 May 2023 17:44:58 -0300 Subject: [PATCH] Melhorias no mapa para permitir embed --- sigi/apps/convenios/admin.py | 5 +- sigi/apps/convenios/models.py | 15 + sigi/apps/home/static/home/css/openmap.css | 79 ++++- sigi/apps/home/templates/home/mapfilter.html | 303 +++++++----------- sigi/apps/home/templates/home/openmap.html | 29 +- .../home/templates/home/openmapdetail.html | 68 ++-- sigi/apps/home/views.py | 15 +- sigi/apps/servicos/urls.py | 4 +- sigi/apps/servicos/views.py | 15 +- 9 files changed, 299 insertions(+), 234 deletions(-) diff --git a/sigi/apps/convenios/admin.py b/sigi/apps/convenios/admin.py index 74160fb..b186222 100644 --- a/sigi/apps/convenios/admin.py +++ b/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"" - f"https://adm.senado.gov.br/gestao-contratos/api/" - f"{obj.id_contrato_gescon}" + f"{obj.id_contrato_gescon}" ) link_gescon.short_description = _("Download MINUTA ASSINADA do Gescon") diff --git a/sigi/apps/convenios/models.py b/sigi/apps/convenios/models.py index ec64325..7d42610 100644 --- a/sigi/apps/convenios/models.py +++ b/sigi/apps/convenios/models.py @@ -374,6 +374,21 @@ class Convenio(models.Model): else: return "visibility_off" + 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 diff --git a/sigi/apps/home/static/home/css/openmap.css b/sigi/apps/home/static/home/css/openmap.css index bfda598..81712ac 100644 --- a/sigi/apps/home/static/home/css/openmap.css +++ b/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; } \ No newline at end of file diff --git a/sigi/apps/home/templates/home/mapfilter.html b/sigi/apps/home/templates/home/mapfilter.html index 62824e9..fc0f9e3 100644 --- a/sigi/apps/home/templates/home/mapfilter.html +++ b/sigi/apps/home/templates/home/mapfilter.html @@ -1,189 +1,124 @@ -{% load i18n material %} +{% load i18n %} -
- {% if not mobile %} - - {% endif %} -
- {{ csrftoken }} -
- -
\ No newline at end of file + diff --git a/sigi/apps/home/templates/home/openmap.html b/sigi/apps/home/templates/home/openmap.html index 3e4d0b2..991cc3f 100644 --- a/sigi/apps/home/templates/home/openmap.html +++ b/sigi/apps/home/templates/home/openmap.html @@ -54,17 +54,28 @@ {% endblock %} {% block side_nav %} -{% if not nav_bar_minimized %} - -{% endif %} -
- {% include 'home/mapfilter.html' with mobile=True %} -
{% endblock %} +{% block coltype %}{{ block.super }}{% if is_popup %} embed-map-content{% endif %} +{% endblock %} {% block content %} +
+ +
+
+ +
+
+
+
+
+ Total de Órgãos selecionados: - +
+ {% include "home/mapfilter.html" %}
@@ -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 = { diff --git a/sigi/apps/home/templates/home/openmapdetail.html b/sigi/apps/home/templates/home/openmapdetail.html index 4945662..73c24e0 100644 --- a/sigi/apps/home/templates/home/openmapdetail.html +++ b/sigi/apps/home/templates/home/openmapdetail.html @@ -1,23 +1,47 @@ -
-
- {{ orgao.nome }} -
-
- - - {% if orgao.data_instalacao %}{% endif %} - - {% if orgao.telefones.all %}{% endif %} - {% if orgao.email %}{% endif %} - {% if orgao.convenio_set.all %} - +
CNPJ{{ orgao.cnpj }}
Data de instalação{{ orgao.data_instalacao }}
Endereço
{{ orgao.logradouro }}, {{ orgao.bairro }}, {{ orgao.municipio.nome }}, {{ orgao.municipio.uf.sigla }}, CEP: {{ orgao.cep }}
Telefones{% for telefone in orgao.telefones.all %}{{ telefone.numero }}{% if not forloop.last %}, {% endif %}{% endfor %}
E-mail{{ orgao.email }}
Convênios{% for c in orgao.convenio_set.all %}{{ c }}{% if not forloop.last %}, {% endif %}{% endfor %}
+ + - {% endif %} - {% if orgao.gerentes_interlegis.all %} - - {% endif %} -
+ {% 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 %} -
Serviços{% for s in orgao.servico_set.all %}{% if s.url %}{{ s }}{% else %}{{ s }}{% endif %}{% if not forloop.last %}, {% endif %}{% endfor %}
Gerentes{% for g in orgao.gerentes_interlegis.all %}{{ g.nome_completo }}{% if not forloop.last %}, {% endif %} {% endfor %}
-
-
\ No newline at end of file + + {{ orgao }} + + + + Endereço
{{ orgao.logradouro }}, {{ orgao.bairro }}, {{ orgao.municipio.nome }}, {{ orgao.municipio.uf.sigla }}, CEP: {{ orgao.cep }}
+ {% if telefones %} + + Telefones + + {% for telefone in telefones %} + {{ telefone }} + {% if not forloop.last %}, {% endif %} + {% endfor %} + + + {% endif %} + {% if orgao.email %}E-mail{{ orgao.email }}{% endif %} + {% if orgao.convenio_set.all %} + + Convênios + + {% for c in orgao.convenio_set.all %} + {% if user.is_staff %} + + {{ c.projeto.sigla }} ({{ c.get_status }}) + + {% else %} + {{ c.projeto.sigla }} ({{ c.get_status }}) + {% endif %} + {% if not forloop.last %}, {% endif %} + {% endfor %} + + + {% endif %} + {% if orgao.servico_set.all %} + Serviços{% for s in servicos.all %}{% if s.url %}{{ s }}{% else %}{{ s }}{% endif %}{% if not forloop.last %}, {% endif %}{% endfor %} + {% endif %} + \ No newline at end of file diff --git a/sigi/apps/home/views.py b/sigi/apps/home/views.py index 32ec260..38bde96 100644 --- a/sigi/apps/home/views.py +++ b/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): diff --git a/sigi/apps/servicos/urls.py b/sigi/apps/servicos/urls.py index 8f7e099..3f8ffca 100644 --- a/sigi/apps/servicos/urls.py +++ b/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//", + "casasatendidas//", views.CasasAtendidasListView.as_view(), name="servicos_casas_atendidas", ), diff --git a/sigi/apps/servicos/views.py b/sigi/apps/servicos/views.py index 27866af..507a7a6 100644 --- a/sigi/apps/servicos/views.py +++ b/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):