moved hide logic from template to python

This commit is contained in:
Abhimanyu Saharan 2023-05-26 19:38:38 +05:30
parent 49e4704bf7
commit d8915b6d25
3 changed files with 32 additions and 38 deletions

View File

@ -227,6 +227,8 @@ class CustomFieldsMixin(models.Model):
for cf in visible_custom_fields:
value = self.custom_field_data.get(cf.name)
if not value and cf.ui_visibility == CustomFieldVisibilityChoices.VISIBILITY_HIDDEN_IFUNSET:
continue
value = cf.deserialize(value)
groups[cf.group_name][cf] = value

View File

@ -131,25 +131,21 @@
</td>
</tr>
{% for field, value in fields.items %}
{% if field.ui_visibility == 'hidden-ifunset' and not value %}
<!-- Skip hidden fields -->
{% else %}
<tr>
<th scope="row">{{ field }}
{% if field.description %}
<i
class="mdi mdi-information text-primary"
data-bs-toggle="tooltip"
data-bs-placement="right"
title="{{ field.description|escape }}"
></i>
{% endif %}
</th>
<td>
{% customfield_value field value %}
</td>
</tr>
{% endif %}
<tr>
<th scope="row">{{ field }}
{% if field.description %}
<i
class="mdi mdi-information text-primary"
data-bs-toggle="tooltip"
data-bs-placement="right"
title="{{ field.description|escape }}"
></i>
{% endif %}
</th>
<td>
{% customfield_value field value %}
</td>
</tr>
{% endfor %}
{% endfor %}
</table>

View File

@ -11,25 +11,21 @@
{% endif %}
<table class="table table-hover attr-table">
{% for field, value in fields.items %}
{% if field.ui_visibility == 'hidden-ifunset' and not value %}
<!-- Skip hidden fields -->
{% else %}
<tr>
<th scope="row">{{ field }}
{% if field.description %}
<i
class="mdi mdi-information text-primary"
data-bs-toggle="tooltip"
data-bs-placement="right"
title="{{ field.description|escape }}"
></i>
{% endif %}
</th>
<td>
{% customfield_value field value %}
</td>
</tr>
{% endif %}
<tr>
<th scope="row">{{ field }}
{% if field.description %}
<i
class="mdi mdi-information text-primary"
data-bs-toggle="tooltip"
data-bs-placement="right"
title="{{ field.description|escape }}"
></i>
{% endif %}
</th>
<td>
{% customfield_value field value %}
</td>
</tr>
{% endfor %}
</table>
{% endfor %}