mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Closes #8517: Render boolean custom fields as icons in object tables
This commit is contained in:
@ -12,6 +12,7 @@
|
|||||||
* [#8462](https://github.com/netbox-community/netbox/issues/8462) - Linkify manufacturer column in device type table
|
* [#8462](https://github.com/netbox-community/netbox/issues/8462) - Linkify manufacturer column in device type table
|
||||||
* [#8476](https://github.com/netbox-community/netbox/issues/8476) - Bring the ASN Web UI up to the standard set by other objects
|
* [#8476](https://github.com/netbox-community/netbox/issues/8476) - Bring the ASN Web UI up to the standard set by other objects
|
||||||
* [#8494](https://github.com/netbox-community/netbox/issues/8494) - Include locations count under tenant view
|
* [#8494](https://github.com/netbox-community/netbox/issues/8494) - Include locations count under tenant view
|
||||||
|
* [#8517](https://github.com/netbox-community/netbox/issues/8517) - Render boolean custom fields as icons in object tables
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
|
@ -414,13 +414,23 @@ class CustomFieldColumn(tables.Column):
|
|||||||
def render(self, value):
|
def render(self, value):
|
||||||
if isinstance(value, list):
|
if isinstance(value, list):
|
||||||
return ', '.join(v for v in value)
|
return ', '.join(v for v in value)
|
||||||
|
elif self.customfield.type == CustomFieldTypeChoices.TYPE_BOOLEAN and value is True:
|
||||||
|
return mark_safe('<i class="mdi mdi-check-bold text-success"></i>')
|
||||||
|
elif self.customfield.type == CustomFieldTypeChoices.TYPE_BOOLEAN and value is False:
|
||||||
|
return mark_safe('<i class="mdi mdi-close-thick text-danger"></i>')
|
||||||
elif self.customfield.type == CustomFieldTypeChoices.TYPE_URL:
|
elif self.customfield.type == CustomFieldTypeChoices.TYPE_URL:
|
||||||
# Linkify custom URLs
|
|
||||||
return mark_safe(f'<a href="{value}">{value}</a>')
|
return mark_safe(f'<a href="{value}">{value}</a>')
|
||||||
if value is not None:
|
if value is not None:
|
||||||
return value
|
return value
|
||||||
return self.default
|
return self.default
|
||||||
|
|
||||||
|
def value(self, value):
|
||||||
|
if isinstance(value, list):
|
||||||
|
return ','.join(v for v in value)
|
||||||
|
if value is not None:
|
||||||
|
return value
|
||||||
|
return self.default
|
||||||
|
|
||||||
|
|
||||||
class CustomLinkColumn(tables.Column):
|
class CustomLinkColumn(tables.Column):
|
||||||
"""
|
"""
|
||||||
|
Reference in New Issue
Block a user