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

Fixes #4737: Introduce ColoredLabelColumn for consistent display of colored labels

This commit is contained in:
Jeremy Stretch
2020-06-10 11:38:23 -04:00
parent 16cdf3006f
commit 9abc67bbeb
4 changed files with 23 additions and 28 deletions

View File

@ -3,7 +3,7 @@ from django_tables2.utils import Accessor
from dcim.models import Interface
from tenancy.tables import COL_TENANT
from utilities.tables import BaseTable, TagColumn, ToggleColumn
from utilities.tables import BaseTable, ColoredLabelColumn, TagColumn, ToggleColumn
from .models import Cluster, ClusterGroup, ClusterType, VirtualMachine
CLUSTERTYPE_ACTIONS = """
@ -28,10 +28,6 @@ VIRTUALMACHINE_STATUS = """
<span class="label label-{{ record.get_status_class }}">{{ record.get_status_display }}</span>
"""
VIRTUALMACHINE_ROLE = """
{% if record.role %}<label class="label" style="background-color: #{{ record.role.color }}">{{ value }}</label>{% else %}&mdash;{% endif %}
"""
VIRTUALMACHINE_PRIMARY_IP = """
{{ record.primary_ip6.address.ip|default:"" }}
{% if record.primary_ip6 and record.primary_ip4 %}<br />{% endif %}
@ -132,9 +128,7 @@ class VirtualMachineTable(BaseTable):
viewname='virtualization:cluster',
args=[Accessor('cluster.pk')]
)
role = tables.TemplateColumn(
template_code=VIRTUALMACHINE_ROLE
)
role = ColoredLabelColumn()
tenant = tables.TemplateColumn(
template_code=COL_TENANT
)