Browse Source

Correção de bugs. Gertiq #191173

dependabot/pip/requirements/django-5.0.8 3.0.93
Sesostris Vieira 5 months ago
parent
commit
0c49be2105
  1. 12
      sigi/apps/home/views.py
  2. 20
      sigi/apps/utils/templatetags/sigi_tags.py

12
sigi/apps/home/views.py

@ -119,6 +119,7 @@ class HomeView(LoginRequiredMixin, TemplateView):
template_name = "home/public_site/index.html"
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
user = self.request.user
casa_id = self.request.GET.get(
"id", self.request.session.get("casa_id", None)
@ -136,18 +137,17 @@ class HomeView(LoginRequiredMixin, TemplateView):
casa = None
if casa:
self.request.session["casa_id"] = casa.id
ocorrencias = casa.ocorrencia_set.filter(
context["ocorrencias"] = casa.ocorrencia_set.filter(
status__in=[
Ocorrencia.STATUS_ABERTO,
Ocorrencia.STATUS_REABERTO,
]
)[:5]
context["servicos"] = casa.servico_set.filter(
data_desativacao=None
)
servicos = casa.servico_set.filter(data_desativacao=None)
context = super().get_context_data(**kwargs)
context["casas"] = casas.values()
context["casa"] = casa
context["ocorrencias"] = ocorrencias[:5]
context["servicos"] = servicos
return context
@ -1253,7 +1253,7 @@ def busca_informacoes_camara(tipos=["CM"], label_tipo=_("Câmaras Municipais")):
df = (
pd.DataFrame.from_dict(dataset, orient="index")
.replace(np.NaN, 0)
.replace(np.nan, 0)
.convert_dtypes()
)

20
sigi/apps/utils/templatetags/sigi_tags.py

@ -40,14 +40,18 @@ def multiply(value, arg):
@register.filter
def valueof(obj, attr_name):
if hasattr(obj, attr_name):
return getattr(obj, attr_name)
if attr_name in obj:
return obj[attr_name]
if isinstance(obj, models.Model):
for part in attr_name.split("__"):
obj = getattr(obj, part)
return str(obj)
try:
if hasattr(obj, attr_name):
return getattr(obj, attr_name)
if isinstance(obj, models.Model):
for part in attr_name.split("__"):
obj = getattr(obj, part)
return str(obj)
if attr_name in obj:
return obj[attr_name]
except:
pass
return None
@register.filter

Loading…
Cancel
Save