-
- CNPJ | {{ orgao.cnpj }} |
- {% if orgao.data_instalacao %}Data de instalação | {{ orgao.data_instalacao }} |
{% endif %}
- Endereço | {{ orgao.logradouro }}, {{ orgao.bairro }}, {{ orgao.municipio.nome }}, {{ orgao.municipio.uf.sigla }}, CEP: {{ orgao.cep }} |
- {% if orgao.telefones.all %}Telefones | {% for telefone in orgao.telefones.all %}{{ telefone.numero }}{% 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 %}{{ c }}{% if not forloop.last %}, {% endif %}{% endfor %} |
+
+
+
+ {% 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 %} |
- {% endif %}
- {% if orgao.gerentes_interlegis.all %}
- Gerentes | {% for g in orgao.gerentes_interlegis.all %}{{ g.nome_completo }}{% if not forloop.last %}, {% endif %} {% endfor %} |
- {% endif %}
-
-
-
\ 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):