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:
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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">—</span>
|
||||
{% endif %}
|
||||
|
@ -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 %}
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
5
netbox/utilities/templates/helpers/checkmark.html
Normal file
5
netbox/utilities/templates/helpers/checkmark.html
Normal 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 %}
|
@ -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 {
|
||||
|
Reference in New Issue
Block a user