1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Closes #8182: Introduce checkmark template tag

This commit is contained in:
jeremystretch
2021-12-29 10:26:42 -05:00
parent f2aa35d3d2
commit 82a0240d2e
16 changed files with 43 additions and 123 deletions

View File

@ -40,13 +40,7 @@
</tr>
<tr>
<th scope="row">VM Role</th>
<td>
{% if object.vm_role %}
<i class="mdi mdi-check-bold text-success" title="Yes"></i>
{% else %}
<i class="mdi mdi-close-thick text-danger" title="No"></i>
{% endif %}
</td>
<td>{% checkmark object.vm_role %}</td>
</tr>
<tr>
<th scope="row">Devices</th>

View File

@ -33,13 +33,7 @@
</tr>
<tr>
<td>Full Depth</td>
<td>
{% if object.is_full_depth %}
<i class="mdi mdi-check-bold text-success" title="Yes"></i>
{% else %}
<i class="mdi mdi-close-thick text-danger" title="No"></i>
{% endif %}
</td>
<td>{% checkmark object.is_full_depth %}</td>
</tr>
<tr>
<td>Parent/Child</td>

View File

@ -48,23 +48,11 @@
</tr>
<tr>
<th scope="row">Enabled</th>
<td>
{% if object.enabled %}
<i class="mdi mdi-check-bold text-success" title="Yes"></i>
{% else %}
<i class="mdi mdi-close-thick text-danger" title="No"></i>
{% endif %}
</td>
<td>{% checkmark object.enabled %}</td>
</tr>
<tr>
<th scope="row">Management Only</th>
<td>
{% if object.mgmt_only %}
<i class="mdi mdi-check-bold text-success" title="Yes"></i>
{% else %}
<i class="mdi mdi-close-thick text-danger" title="No"></i>
{% endif %}
</td>
<td>{% checkmark object.mgmt_only %}</td>
</tr>
<tr>
<th scope="row">Parent</th>

View File

@ -65,7 +65,7 @@
</td>
<td>
{% if object.master == vc_member %}
<i class="mdi mdi-check-bold text-success"></i>
{% checkmark True %}
{% endif %}
</td>
<td>

View File

@ -29,13 +29,7 @@
</tr>
<tr>
<th scope="row">Required</th>
<td>
{% if object.required %}
<i class="mdi mdi-check-bold text-success" title="Yes"></i>
{% else %}
<i class="mdi mdi-close-thick text-danger" title="No"></i>
{% endif %}
</td>
<td>{% checkmark object.required %}</td>
</tr>
<tr>
<th scope="row">Weight</th>

View File

@ -33,13 +33,7 @@
</tr>
<tr>
<th scope="row">New Window</th>
<td>
{% if object.new_window %}
<i class="mdi mdi-check-bold text-success" title="Yes"></i>
{% else %}
<i class="mdi mdi-close-thick text-danger" title="No"></i>
{% endif %}
</td>
<td>{% checkmark object.new_window %}</td>
</tr>
</table>
</div>

View File

@ -40,13 +40,7 @@
</tr>
<tr>
<th scope="row">Attachment</th>
<td>
{% if object.as_attachment %}
<i class="mdi mdi-check-bold text-success" title="Yes"></i>
{% else %}
<i class="mdi mdi-close-thick text-danger" title="No"></i>
{% endif %}
</td>
<td>{% checkmark object.as_attachment %}</td>
</tr>
</table>
</div>

View File

@ -17,13 +17,7 @@
</tr>
<tr>
<th scope="row">Enabled</th>
<td>
{% if object.enabled %}
<i class="mdi mdi-check-bold text-success" title="Yes"></i>
{% else %}
<i class="mdi mdi-close-thick text-danger" title="No"></i>
{% endif %}
</td>
<td>{% checkmark object.enabled %}</td>
</tr>
</table>
</div>
@ -36,33 +30,15 @@
<table class="table table-hover attr-table">
<tr>
<th scope="row">Create</th>
<td>
{% if object.type_create %}
<i class="mdi mdi-check-bold text-success" title="Yes"></i>
{% else %}
<i class="mdi mdi-close-thick text-danger" title="No"></i>
{% endif %}
</td>
<td>{% checkmark object.type_create %}</td>
</tr>
<tr>
<th scope="row">Update</th>
<td>
{% if object.type_update %}
<i class="mdi mdi-check-bold text-success" title="Yes"></i>
{% else %}
<i class="mdi mdi-close-thick text-danger" title="No"></i>
{% endif %}
</td>
<td>{% checkmark object.type_update %}</td>
</tr>
<tr>
<th scope="row">Delete</th>
<td>
{% if object.type_delete %}
<i class="mdi mdi-check-bold text-success" title="Yes"></i>
{% else %}
<i class="mdi mdi-close-thick text-danger" title="No"></i>
{% endif %}
</td>
<td>{% checkmark object.type_delete %}</td>
</tr>
</table>
</div>
@ -100,13 +76,7 @@
<table class="table table-hover attr-table">
<tr>
<th scope="row">SSL Verification</th>
<td>
{% if object.ssl_verification %}
<i class="mdi mdi-check-bold text-success" title="Yes"></i>
{% else %}
<i class="mdi mdi-close-thick text-danger" title="No"></i>
{% endif %}
</td>
<td>{% checkmark object.ssl_verification %}</td>
</tr>
<tr>
<th scope="row">CA File Path</th>

View File

@ -66,7 +66,7 @@
</td>
<td>
{% if field.required %}
<i class="mdi mdi-check-bold text-success" title="Required"></i>
{% checkmark True true="Required" %}
{% else %}
<span class="text-muted">&mdash;</span>
{% endif %}

View File

@ -15,9 +15,9 @@
{% if field.type == 'longtext' and value %}
{{ value|render_markdown }}
{% elif field.type == 'boolean' and value == True %}
<i class="mdi mdi-check-bold text-success" title="True"></i>
{% checkmark value true="True" %}
{% elif field.type == 'boolean' and value == False %}
<i class="mdi mdi-close-thick text-danger" title="False"></i>
{% checkmark value false="False" %}
{% elif field.type == 'url' and value %}
<a href="{{ value }}">{{ value|truncatechars:70 }}</a>
{% elif field.type == 'json' and value %}

View File

@ -94,13 +94,7 @@
</tr>
<tr>
<th scope="row">Is a pool</th>
<td>
{% if object.is_pool %}
<i class="mdi mdi-check-bold text-success" title="Yes"></i>
{% else %}
<i class="mdi mdi-close-thick text-danger" title="No"></i>
{% endif %}
</td>
<td>{% checkmark object.is_pool %}</td>
</tr>
</table>
</div>

View File

@ -30,13 +30,7 @@
</tr>
<tr>
<th scope="row">Private</th>
<td>
{% if object.is_private %}
<i class="mdi mdi-check-bold text-success" title="Yes"></i>
{% else %}
<i class="mdi mdi-close-thick text-danger" title="No"></i>
{% endif %}
</td>
<td>{% checkmark object.is_private %}</td>
</tr>
<tr>
<th scope="row">Aggregates</th>

View File

@ -30,13 +30,7 @@
</tr>
<tr>
<th scope="row">Unique IP Space</th>
<td>
{% if object.enforce_unique %}
<i class="mdi mdi-check-bold text-success" title="Yes"></i>
{% else %}
<i class="mdi mdi-close-thick text-danger" title="No"></i>
{% endif %}
</td>
<td>{% checkmark object.enforce_unique %}</td>
</tr>
<tr>
<th scope="row">Description</th>

View File

@ -35,23 +35,11 @@
</tr>
<tr>
<th scope="row">Superuser</th>
<td>
{% if request.user.is_superuser %}
<i class="mdi mdi-check-bold text-success" title="Yes"></i>
{% else %}
<i class="mdi mdi-close-thick text-danger" title="No"></i>
{% endif %}
</td>
<td>{% checkmark request.user.is_superuser %}</td>
</tr>
<tr>
<th scope="row">Admin Access</th>
<td>
{% if request.user.is_staff %}
<i class="mdi mdi-check-bold text-success" title="Yes"></i>
{% else %}
<i class="mdi mdi-close-thick text-danger" title="No"></i>
{% endif %}
</td>
<td>{% checkmark request.user.is_staff %}</td>
</tr>
</table>
</div>

View File

@ -0,0 +1,5 @@
{% if value %}
<i class="mdi mdi-check-bold text-success" title="{{ true_label }}"></i>
{% elif show_false %}
<i class="mdi mdi-close-thick text-danger" title="{{ false_label }}"></i>
{% endif %}

View File

@ -426,6 +426,23 @@ def badge(value, bg_class='secondary', show_empty=False):
}
@register.inclusion_tag('helpers/checkmark.html')
def checkmark(value, show_false=True, true='Yes', false='No'):
"""
Display either a green checkmark or red X to indicate a boolean value.
:param show_false: Display a red X if the value is False
:param true: Text label for true value
:param false: Text label for false value
"""
return {
'value': bool(value),
'show_false': show_false,
'true_label': true,
'false_label': false,
}
@register.inclusion_tag('helpers/table_config_form.html')
def table_config_form(table, table_name=None):
return {