From db3f47859867aa339c3547d01485c593af2abca9 Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Wed, 2 Feb 2022 16:24:51 -0500 Subject: [PATCH] Closes #8517: Render boolean custom fields as icons in object tables --- docs/release-notes/version-3.1.md | 1 + netbox/utilities/tables.py | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/release-notes/version-3.1.md b/docs/release-notes/version-3.1.md index 7cce525ed..ce50026b8 100644 --- a/docs/release-notes/version-3.1.md +++ b/docs/release-notes/version-3.1.md @@ -12,6 +12,7 @@ * [#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 * [#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 diff --git a/netbox/utilities/tables.py b/netbox/utilities/tables.py index c640e0e85..0b67434b1 100644 --- a/netbox/utilities/tables.py +++ b/netbox/utilities/tables.py @@ -414,13 +414,23 @@ class CustomFieldColumn(tables.Column): def render(self, value): if isinstance(value, list): return ', '.join(v for v in value) + elif self.customfield.type == CustomFieldTypeChoices.TYPE_BOOLEAN and value is True: + return mark_safe('') + elif self.customfield.type == CustomFieldTypeChoices.TYPE_BOOLEAN and value is False: + return mark_safe('') elif self.customfield.type == CustomFieldTypeChoices.TYPE_URL: - # Linkify custom URLs return mark_safe(f'{value}') if value is not None: return value 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): """