Browse Source

Corrige bug relatado no gertiq #188667

dependabot/pip/requirements/django-5.0.8
Sesostris Vieira 5 months ago
parent
commit
e82b99ac2e
  1. 17
      sigi/apps/convenios/models.py
  2. 5
      sigi/apps/utils/templatetags/sigi_tags.py
  3. 15
      sigi/templates/admin/tabs_change_form.html

17
sigi/apps/convenios/models.py

@ -422,14 +422,6 @@ class Convenio(models.Model):
) )
) )
} }
if self.data_retorno_assinatura is None:
errors["data_retorno_assinatura"] = ValidationError(
_("Obrigatório para convênios vigentes")
)
if self.data_termino_vigencia is None:
errors["data_termino_vigencia"] = ValidationError(
_("Obrigatório para convênios vigentes")
)
raise ValidationError(errors) raise ValidationError(errors)
else: else:
if ( if (
@ -444,16 +436,7 @@ class Convenio(models.Model):
) )
) )
} }
if self.data_retorno_assinatura is not None:
errors["data_retorno_assinatura"] = ValidationError(
_("Não pode ser preenchido para convênios pendentes")
)
if self.data_termino_vigencia is not None:
errors["data_termino_vigencia"] = ValidationError(
_("Não pode ser preenchido para convênios pendentes")
)
raise ValidationError(errors) raise ValidationError(errors)
return super().clean() return super().clean()
def save(self, *args, **kwargs): def save(self, *args, **kwargs):

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

@ -48,3 +48,8 @@ def valueof(obj, attr_name):
for part in attr_name.split("__"): for part in attr_name.split("__"):
obj = getattr(obj, part) obj = getattr(obj, part)
return str(obj) return str(obj)
@register.filter
def has_errors(obj):
return any([obj.form.has_error(field_name) for field_name in obj.fields])

15
sigi/templates/admin/tabs_change_form.html

@ -1,5 +1,5 @@
{% extends "admin/change_form.html" %} {% extends "admin/change_form.html" %}
{% load i18n %} {% load i18n sigi_tags %}
{% block extrastyle %} {% block extrastyle %}
{{ block.super }} {{ block.super }}
@ -14,12 +14,22 @@
{% endblock %} {% endblock %}
{% block form_top %} {% block form_top %}
<p class="errornote">
{% if errors|length > 0 %}
{% translate "As abas com erro estão marcadas com " %}
<i class="material-icons">error</i>
{% endif %}
</p>
<div class="row"> <div class="row">
<div class="col s12"> <div class="col s12">
<ul class="tabs"> <ul class="tabs">
{% for fieldset in adminform %} {% for fieldset in adminform %}
<li class="tab"> <li class="tab">
<a href="#{{ fieldset.name|default:'geral'|slugify }}"> <a href="#{{ fieldset.name|default:'geral'|slugify }}">
{% if fieldset|has_errors %}
<i class="material-icons">error</i>
{% endif %}
{{ fieldset.name|default:_("Geral") }} {{ fieldset.name|default:_("Geral") }}
</a> </a>
</li> </li>
@ -27,6 +37,9 @@
{% for inline_admin_formset in inline_admin_formsets %} {% for inline_admin_formset in inline_admin_formsets %}
<li class="tab"> <li class="tab">
<a href="#{{ inline_admin_formset.opts.verbose_name_plural|slugify }}"> <a href="#{{ inline_admin_formset.opts.verbose_name_plural|slugify }}">
{% if inline_admin_formset.formset.total_error_count > 0 %}
<i class="material-icons">error</i>
{% endif %}
{{ inline_admin_formset.opts.verbose_name_plural|default:_("inline") }} {{ inline_admin_formset.opts.verbose_name_plural|default:_("inline") }}
</a> </a>
</li> </li>

Loading…
Cancel
Save