diff --git a/netbox/dcim/tables.py b/netbox/dcim/tables.py index b78c9ce55..46a5da3f3 100644 --- a/netbox/dcim/tables.py +++ b/netbox/dcim/tables.py @@ -4,7 +4,7 @@ import django_tables2 as tables from django_tables2.utils import Accessor from tenancy.tables import COL_TENANT -from utilities.tables import BaseTable, ToggleColumn +from utilities.tables import BaseTable, BooleanColumn, ToggleColumn from .models import ( ConsolePort, ConsolePortTemplate, ConsoleServerPort, ConsoleServerPortTemplate, Device, DeviceBay, DeviceBayTemplate, DeviceRole, DeviceType, Interface, InterfaceTemplate, InventoryItem, Manufacturer, Platform, @@ -346,10 +346,10 @@ class DeviceTypeTable(BaseTable): args=[Accessor('pk')], verbose_name='Device Type' ) - is_full_depth = tables.BooleanColumn(verbose_name='Full Depth') - is_console_server = tables.BooleanColumn(verbose_name='CS') - is_pdu = tables.BooleanColumn(verbose_name='PDU') - is_network_device = tables.BooleanColumn(verbose_name='Net') + is_full_depth = BooleanColumn(verbose_name='Full Depth') + is_console_server = BooleanColumn(verbose_name='CS') + is_pdu = BooleanColumn(verbose_name='PDU') + is_network_device = BooleanColumn(verbose_name='Net') subdevice_role = tables.TemplateColumn( template_code=SUBDEVICE_ROLE_TEMPLATE, verbose_name='Subdevice Role' diff --git a/netbox/extras/tables.py b/netbox/extras/tables.py index 4a7e987cb..364da9ebb 100644 --- a/netbox/extras/tables.py +++ b/netbox/extras/tables.py @@ -3,7 +3,7 @@ from __future__ import unicode_literals import django_tables2 as tables from taggit.models import Tag -from utilities.tables import BaseTable, ToggleColumn +from utilities.tables import BaseTable, BooleanColumn, ToggleColumn from .models import ConfigContext, ObjectChange TAG_ACTIONS = """ @@ -59,7 +59,7 @@ class TagTable(BaseTable): class ConfigContextTable(BaseTable): pk = ToggleColumn() name = tables.LinkColumn() - is_active = tables.BooleanColumn( + is_active = BooleanColumn( verbose_name='Active' ) actions = tables.TemplateColumn( diff --git a/netbox/ipam/tables.py b/netbox/ipam/tables.py index 2cb1c6606..e444cfe28 100644 --- a/netbox/ipam/tables.py +++ b/netbox/ipam/tables.py @@ -5,7 +5,7 @@ from django_tables2.utils import Accessor from dcim.models import Interface from tenancy.tables import COL_TENANT -from utilities.tables import BaseTable, ToggleColumn +from utilities.tables import BaseTable, BooleanColumn, ToggleColumn from .models import Aggregate, IPAddress, Prefix, RIR, Role, Service, VLAN, VLANGroup, VRF RIR_UTILIZATION = """ @@ -193,7 +193,7 @@ class VRFTable(BaseTable): class RIRTable(BaseTable): pk = ToggleColumn() name = tables.LinkColumn(verbose_name='Name') - is_private = tables.BooleanColumn(verbose_name='Private') + is_private = BooleanColumn(verbose_name='Private') aggregate_count = tables.Column(verbose_name='Aggregates') actions = tables.TemplateColumn(template_code=RIR_ACTIONS, attrs={'td': {'class': 'text-right'}}, verbose_name='') diff --git a/netbox/utilities/tables.py b/netbox/utilities/tables.py index 8694d986b..a9f1044d6 100644 --- a/netbox/utilities/tables.py +++ b/netbox/utilities/tables.py @@ -31,3 +31,18 @@ class ToggleColumn(tables.CheckBoxColumn): @property def header(self): return mark_safe('') + + +class BooleanColumn(tables.Column): + """ + Custom implementation of BooleanColumn to render a nicely-formatted checkmark or X icon instead of a Unicode + character. + """ + def render(self, value): + if value is True: + rendered = '' + elif value is False: + rendered = '' + else: + rendered = '' + return mark_safe(rendered)