mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-22 20:12:00 -06:00
Standardize on get_FOO_color() method for returning ChoiceField colors
This commit is contained in:
parent
9cf9f1bdba
commit
1319b62acb
@ -132,6 +132,9 @@ class Circuit(NetBoxModel):
|
|||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse('circuits:circuit', args=[self.pk])
|
return reverse('circuits:circuit', args=[self.pk])
|
||||||
|
|
||||||
|
def get_status_color(self):
|
||||||
|
return CircuitStatusChoices.colors.get(self.status)
|
||||||
|
|
||||||
|
|
||||||
class CircuitTermination(WebhooksMixin, ChangeLoggedModel, LinkTermination):
|
class CircuitTermination(WebhooksMixin, ChangeLoggedModel, LinkTermination):
|
||||||
circuit = models.ForeignKey(
|
circuit = models.ForeignKey(
|
||||||
|
@ -286,6 +286,9 @@ class Cable(NetBoxModel):
|
|||||||
# Update the private pk used in __str__ in case this is a new object (i.e. just got its pk)
|
# Update the private pk used in __str__ in case this is a new object (i.e. just got its pk)
|
||||||
self._pk = self.pk
|
self._pk = self.pk
|
||||||
|
|
||||||
|
def get_status_color(self):
|
||||||
|
return LinkStatusChoices.colors.get(self.status)
|
||||||
|
|
||||||
def get_compatible_types(self):
|
def get_compatible_types(self):
|
||||||
"""
|
"""
|
||||||
Return all termination types compatible with termination A.
|
Return all termination types compatible with termination A.
|
||||||
|
@ -1001,6 +1001,9 @@ class Device(NetBoxModel, ConfigContextModel):
|
|||||||
"""
|
"""
|
||||||
return Device.objects.filter(parent_bay__device=self.pk)
|
return Device.objects.filter(parent_bay__device=self.pk)
|
||||||
|
|
||||||
|
def get_status_color(self):
|
||||||
|
return DeviceStatusChoices.colors.get(self.status)
|
||||||
|
|
||||||
|
|
||||||
class Module(NetBoxModel, ConfigContextModel):
|
class Module(NetBoxModel, ConfigContextModel):
|
||||||
"""
|
"""
|
||||||
|
@ -169,3 +169,9 @@ class PowerFeed(NetBoxModel, PathEndpoint, LinkTermination):
|
|||||||
@property
|
@property
|
||||||
def parent_object(self):
|
def parent_object(self):
|
||||||
return self.power_panel
|
return self.power_panel
|
||||||
|
|
||||||
|
def get_type_color(self):
|
||||||
|
return PowerFeedTypeChoices.colors.get(self.type)
|
||||||
|
|
||||||
|
def get_status_color(self):
|
||||||
|
return PowerFeedStatusChoices.colors.get(self.status)
|
||||||
|
@ -247,6 +247,9 @@ class Rack(NetBoxModel):
|
|||||||
else:
|
else:
|
||||||
return reversed(range(1, self.u_height + 1))
|
return reversed(range(1, self.u_height + 1))
|
||||||
|
|
||||||
|
def get_status_color(self):
|
||||||
|
return RackStatusChoices.colors.get(self.status)
|
||||||
|
|
||||||
def get_rack_units(self, user=None, face=DeviceFaceChoices.FACE_FRONT, exclude=None, expand_devices=True):
|
def get_rack_units(self, user=None, face=DeviceFaceChoices.FACE_FRONT, exclude=None, expand_devices=True):
|
||||||
"""
|
"""
|
||||||
Return a list of rack units as dictionaries. Example: {'device': None, 'face': 0, 'id': 48, 'name': 'U48'}
|
Return a list of rack units as dictionaries. Example: {'device': None, 'face': 0, 'id': 48, 'name': 'U48'}
|
||||||
|
@ -309,6 +309,9 @@ class Site(NetBoxModel):
|
|||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse('dcim:site', args=[self.pk])
|
return reverse('dcim:site', args=[self.pk])
|
||||||
|
|
||||||
|
def get_status_color(self):
|
||||||
|
return SiteStatusChoices.colors.get(self.status)
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Locations
|
# Locations
|
||||||
|
@ -31,7 +31,7 @@ DEVICE_LINK = """
|
|||||||
|
|
||||||
DEVICEBAY_STATUS = """
|
DEVICEBAY_STATUS = """
|
||||||
{% if record.installed_device_id %}
|
{% if record.installed_device_id %}
|
||||||
<span class="badge bg-{{ record.installed_device.get_status_class }}">
|
<span class="badge bg-{{ record.installed_device.get_status_color }}">
|
||||||
{{ record.installed_device.get_status_display }}
|
{{ record.installed_device.get_status_display }}
|
||||||
</span>
|
</span>
|
||||||
{% else %}
|
{% else %}
|
||||||
@ -43,7 +43,7 @@ INTERFACE_IPADDRESSES = """
|
|||||||
<div class="table-badge-group">
|
<div class="table-badge-group">
|
||||||
{% for ip in record.ip_addresses.all %}
|
{% for ip in record.ip_addresses.all %}
|
||||||
{% if ip.status != 'active' %}
|
{% if ip.status != 'active' %}
|
||||||
<a href="{{ ip.get_absolute_url }}" class="table-badge badge bg-{{ ip.get_status_class }}" data-bs-toggle="tooltip" data-bs-placement="left" title="{{ ip.get_status_display }}">{{ ip }}</a>
|
<a href="{{ ip.get_absolute_url }}" class="table-badge badge bg-{{ ip.get_status_color }}" data-bs-toggle="tooltip" data-bs-placement="left" title="{{ ip.get_status_display }}">{{ ip }}</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="{{ ip.get_absolute_url }}" class="table-badge">{{ ip }}</a>
|
<a href="{{ ip.get_absolute_url }}" class="table-badge">{{ ip }}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -102,3 +102,6 @@ class ObjectChange(models.Model):
|
|||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse('extras:objectchange', args=[self.pk])
|
return reverse('extras:objectchange', args=[self.pk])
|
||||||
|
|
||||||
|
def get_action_color(self):
|
||||||
|
return ObjectChangeActionChoices.colors.get(self.action)
|
||||||
|
@ -458,6 +458,9 @@ class JournalEntry(WebhooksMixin, ChangeLoggedModel):
|
|||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse('extras:journalentry', args=[self.pk])
|
return reverse('extras:journalentry', args=[self.pk])
|
||||||
|
|
||||||
|
def get_kind_color(self):
|
||||||
|
return JournalEntryKindChoices.colors.get(self.kind)
|
||||||
|
|
||||||
|
|
||||||
class JobResult(models.Model):
|
class JobResult(models.Model):
|
||||||
"""
|
"""
|
||||||
|
@ -437,6 +437,9 @@ class Prefix(GetAvailablePrefixesMixin, NetBoxModel):
|
|||||||
self.prefix.prefixlen = value
|
self.prefix.prefixlen = value
|
||||||
prefix_length = property(fset=_set_prefix_length)
|
prefix_length = property(fset=_set_prefix_length)
|
||||||
|
|
||||||
|
def get_status_color(self):
|
||||||
|
return PrefixStatusChoices.colors.get(self.status)
|
||||||
|
|
||||||
def get_parents(self, include_self=False):
|
def get_parents(self, include_self=False):
|
||||||
"""
|
"""
|
||||||
Return all containing Prefixes in the hierarchy.
|
Return all containing Prefixes in the hierarchy.
|
||||||
@ -703,6 +706,9 @@ class IPRange(NetBoxModel):
|
|||||||
self.end_address.prefixlen = value
|
self.end_address.prefixlen = value
|
||||||
prefix_length = property(fset=_set_prefix_length)
|
prefix_length = property(fset=_set_prefix_length)
|
||||||
|
|
||||||
|
def get_status_color(self):
|
||||||
|
return IPRangeStatusChoices.colors.get(self.status)
|
||||||
|
|
||||||
def get_child_ips(self):
|
def get_child_ips(self):
|
||||||
"""
|
"""
|
||||||
Return all IPAddresses within this IPRange and VRF.
|
Return all IPAddresses within this IPRange and VRF.
|
||||||
@ -916,3 +922,9 @@ class IPAddress(NetBoxModel):
|
|||||||
if self.address is not None:
|
if self.address is not None:
|
||||||
self.address.prefixlen = value
|
self.address.prefixlen = value
|
||||||
mask_length = property(fset=_set_mask_length)
|
mask_length = property(fset=_set_mask_length)
|
||||||
|
|
||||||
|
def get_status_color(self):
|
||||||
|
return IPAddressStatusChoices.colors.get(self.status)
|
||||||
|
|
||||||
|
def get_role_color(self):
|
||||||
|
return IPAddressRoleChoices.colors.get(self.role)
|
||||||
|
@ -211,6 +211,9 @@ class VLAN(NetBoxModel):
|
|||||||
f"{self.group}"
|
f"{self.group}"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
def get_status_color(self):
|
||||||
|
return VLANStatusChoices.colors.get(self.status)
|
||||||
|
|
||||||
def get_interfaces(self):
|
def get_interfaces(self):
|
||||||
# Return all device interfaces assigned to this VLAN
|
# Return all device interfaces assigned to this VLAN
|
||||||
return Interface.objects.filter(
|
return Interface.objects.filter(
|
||||||
|
@ -167,19 +167,20 @@ class ActionsColumn(tables.Column):
|
|||||||
|
|
||||||
class ChoiceFieldColumn(tables.Column):
|
class ChoiceFieldColumn(tables.Column):
|
||||||
"""
|
"""
|
||||||
Render a model's static ChoiceField with its value from `get_FOO_display()` as a colored badge. Colors are derived
|
Render a model's static ChoiceField with its value from `get_FOO_display()` as a colored badge. Background color is
|
||||||
from the ChoiceSet associated with the model field.
|
set by the instance's get_FOO_color() method, if defined.
|
||||||
"""
|
"""
|
||||||
|
DEFAULT_BG_COLOR = 'secondary'
|
||||||
|
|
||||||
def render(self, record, bound_column, value):
|
def render(self, record, bound_column, value):
|
||||||
if value in self.empty_values:
|
if value in self.empty_values:
|
||||||
return self.default
|
return self.default
|
||||||
|
|
||||||
accessor = tables.A(bound_column.accessor)
|
# Determine the background color to use (try calling object.get_FOO_color())
|
||||||
field = accessor.get_field(record)
|
try:
|
||||||
raw_value = accessor.resolve(record) # `value` is from get_FOO_display()
|
bg_color = getattr(record, f'get_{bound_column.name}_color')()
|
||||||
|
except AttributeError:
|
||||||
# Determine the background color to use
|
bg_color = self.DEFAULT_BG_COLOR
|
||||||
bg_color = field.choices.colors.get(raw_value, 'secondary')
|
|
||||||
|
|
||||||
return mark_safe(f'<span class="badge bg-{bg_color}">{value}</span>')
|
return mark_safe(f'<span class="badge bg-{bg_color}">{value}</span>')
|
||||||
|
|
||||||
|
@ -32,9 +32,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Status</th>
|
<th scope="row">Status</th>
|
||||||
<td>
|
<td>{% badge object.get_status_display bg_color=object.get_status_color %}</td>
|
||||||
<span class="badge bg-{{ object.get_status_class }}">{{ object.get_status_display }}</span>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Tenant</th>
|
<th scope="row">Tenant</th>
|
||||||
|
@ -19,9 +19,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Status</th>
|
<th scope="row">Status</th>
|
||||||
<td>
|
<td>{% badge object.get_status_display bg_color=object.get_status_color %}</td>
|
||||||
<span class="badge bg-{{ object.get_status_class }}">{{ object.get_status_display }}</span>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Tenant</th>
|
<th scope="row">Tenant</th>
|
||||||
|
@ -163,9 +163,7 @@
|
|||||||
<table class="table table-hover attr-table">
|
<table class="table table-hover attr-table">
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Status</th>
|
<th scope="row">Status</th>
|
||||||
<td>
|
<td>{% badge object.get_status_display bg_color=object.get_status_color %}</td>
|
||||||
<span class="badge bg-{{ object.get_status_class }}">{{ object.get_status_display }}</span>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Role</th>
|
<th scope="row">Role</th>
|
||||||
|
@ -40,15 +40,11 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Type</th>
|
<th scope="row">Type</th>
|
||||||
<td>
|
<td>{% badge object.get_type_display bg_color=object.get_type_color %}</td>
|
||||||
<span class="badge bg-{{ object.get_type_class }}">{{ object.get_type_display }}</span>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Status</th>
|
<th scope="row">Status</th>
|
||||||
<td>
|
<td>{% badge object.get_status_display bg_color=object.get_status_color %}</td>
|
||||||
<span class="badge bg-{{ object.get_status_class }}">{{ object.get_status_display }}</span>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Connected Device</th>
|
<th scope="row">Connected Device</th>
|
||||||
|
@ -76,9 +76,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Status</th>
|
<th scope="row">Status</th>
|
||||||
<td>
|
<td>{% badge object.get_status_display bg_color=object.get_status_color %}</td>
|
||||||
<span class="badge bg-{{ object.get_status_class }}">{{ object.get_status_display }}</span>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Role</th>
|
<th scope="row">Role</th>
|
||||||
@ -188,10 +186,10 @@
|
|||||||
<a href="{{ powerfeed.get_absolute_url }}">{{ powerfeed.name }}</a>
|
<a href="{{ powerfeed.get_absolute_url }}">{{ powerfeed.name }}</a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<span class="badge bg-{{ powerfeed.get_status_class }}">{{ powerfeed.get_status_display }}</span>
|
{% badge powerfeed.get_status_display bg_color=powerfeed.get_status_color %}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<span class="badge bg-{{ powerfeed.get_type_class }}">{{ powerfeed.get_type_display }}</span>
|
{% badge powerfeed.get_type_display bg_color=powerfeed.get_type_color %}
|
||||||
</td>
|
</td>
|
||||||
{% with power_port=powerfeed.connected_endpoint %}
|
{% with power_port=powerfeed.connected_endpoint %}
|
||||||
{% if power_port %}
|
{% if power_port %}
|
||||||
|
@ -53,9 +53,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Status</th>
|
<th scope="row">Status</th>
|
||||||
<td>
|
<td>{% badge object.get_status_display bg_color=object.get_status_color %}</td>
|
||||||
<span class="badge bg-{{ object.get_status_class }}">{{ object.get_status_display }}</span>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Tenant</th>
|
<th scope="row">Tenant</th>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
{% if cable.length %}
|
{% if cable.length %}
|
||||||
({{ cable.length|floatformat }} {{ cable.get_length_unit_display }})<br />
|
({{ cable.length|floatformat }} {{ cable.get_length_unit_display }})<br />
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<span class="badge bg-{{ cable.get_status_class }}">{{ cable.get_status_display }}</span><br />
|
{% badge object.get_status_display bg_color=object.get_status_color %}<br />
|
||||||
{% for tag in cable.tags.all %}
|
{% for tag in cable.tags.all %}
|
||||||
{% tag tag 'dcim:cable_list' %}
|
{% tag tag 'dcim:cable_list' %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -36,9 +36,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Kind</th>
|
<th scope="row">Kind</th>
|
||||||
<td>
|
<td>{% badge object.get_kind_display bg_color=object.get_kind_color %}</td>
|
||||||
<span class="badge bg-{{ object.get_kind_class }}">{{ object.get_kind_display }}</span>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
@ -52,7 +52,7 @@ Context:
|
|||||||
<li class="nav-item" role="presentation">
|
<li class="nav-item" role="presentation">
|
||||||
<button class="nav-link" id="filters-form-tab" data-bs-toggle="tab" data-bs-target="#filters-form" type="button" role="tab" aria-controls="object-list" aria-selected="false">
|
<button class="nav-link" id="filters-form-tab" data-bs-toggle="tab" data-bs-target="#filters-form" type="button" role="tab" aria-controls="object-list" aria-selected="false">
|
||||||
Filters
|
Filters
|
||||||
{% if filter_form %}{% badge filter_form.changed_data|length bg_class="primary" %}{% endif %}
|
{% if filter_form %}{% badge filter_form.changed_data|length bg_color="primary" %}{% endif %}
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -48,9 +48,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Status</th>
|
<th scope="row">Status</th>
|
||||||
<td>
|
<td>{% badge object.get_status_display bg_color=object.get_status_color %}</td>
|
||||||
<span class="badge bg-{{ object.get_status_class }}">{{ object.get_status_display }}</span>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Role</th>
|
<th scope="row">Role</th>
|
||||||
|
@ -55,9 +55,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Status</th>
|
<th scope="row">Status</th>
|
||||||
<td>
|
<td>{% badge object.get_status_display bg_color=object.get_status_color %}</td>
|
||||||
<span class="badge bg-{{ object.get_status_class }}">{{ object.get_status_display }}</span>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Tenant</th>
|
<th scope="row">Tenant</th>
|
||||||
|
@ -75,9 +75,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Status</th>
|
<th scope="row">Status</th>
|
||||||
<td>
|
<td>{% badge object.get_status_display bg_color=object.get_status_color %}</td>
|
||||||
<span class="badge bg-{{ object.get_status_class }}">{{ object.get_status_display }}</span>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Role</th>
|
<th scope="row">Role</th>
|
||||||
|
@ -58,9 +58,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Status</th>
|
<th scope="row">Status</th>
|
||||||
<td>
|
<td>{% badge object.get_status_display bg_color=object.get_status_color %}</td>
|
||||||
<span class="badge bg-{{ object.get_status_class }}">{{ object.get_status_display }}</span>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Role</th>
|
<th scope="row">Role</th>
|
||||||
|
@ -19,9 +19,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Status</th>
|
<th scope="row">Status</th>
|
||||||
<td>
|
<td>{% badge object.get_status_display bg_color=object.get_status_color %}</td>
|
||||||
<span class="badge bg-{{ object.get_status_class }}">{{ object.get_status_display }}</span>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Role</th>
|
<th scope="row">Role</th>
|
||||||
|
@ -17,9 +17,7 @@
|
|||||||
<table class="table table-hover attr-table">
|
<table class="table table-hover attr-table">
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">Status</th>
|
<th scope="row">Status</th>
|
||||||
<td>
|
<td>{% badge object.get_status_display bg_color=object.get_status_color %}</td>
|
||||||
<span class="badge bg-{{ object.get_status_class }}">{{ object.get_status_display }}</span>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">SSID</th>
|
<th scope="row">SSID</th>
|
||||||
|
@ -1 +1 @@
|
|||||||
{% if value or show_empty %}<span class="badge bg-{{ bg_class }}">{{ value }}</span>{% endif %}
|
{% if value or show_empty %}<span class="badge bg-{{ bg_color }}">{{ value }}</span>{% endif %}
|
||||||
|
@ -19,18 +19,18 @@ def tag(value, viewname=None):
|
|||||||
|
|
||||||
|
|
||||||
@register.inclusion_tag('builtins/badge.html')
|
@register.inclusion_tag('builtins/badge.html')
|
||||||
def badge(value, bg_class='secondary', show_empty=False):
|
def badge(value, bg_color='secondary', show_empty=False):
|
||||||
"""
|
"""
|
||||||
Display the specified number as a badge.
|
Display the specified number as a badge.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
value: The value to be displayed within the badge
|
value: The value to be displayed within the badge
|
||||||
bg_class: Bootstrap 5 background CSS name
|
bg_color: Background color CSS name
|
||||||
show_empty: If true, display the badge even if value is None or zero
|
show_empty: If true, display the badge even if value is None or zero
|
||||||
"""
|
"""
|
||||||
return {
|
return {
|
||||||
'value': value,
|
'value': value,
|
||||||
'bg_class': bg_class,
|
'bg_color': bg_color,
|
||||||
'show_empty': show_empty,
|
'show_empty': show_empty,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,6 +322,9 @@ class VirtualMachine(NetBoxModel, ConfigContextModel):
|
|||||||
field: f"The specified IP address ({ip}) is not assigned to this VM.",
|
field: f"The specified IP address ({ip}) is not assigned to this VM.",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
def get_status_color(self):
|
||||||
|
return VirtualMachineStatusChoices.colors.get(self.status)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def primary_ip(self):
|
def primary_ip(self):
|
||||||
if get_config().PREFER_IPV4 and self.primary_ip4:
|
if get_config().PREFER_IPV4 and self.primary_ip4:
|
||||||
|
@ -177,6 +177,9 @@ class WirelessLink(WirelessAuthenticationBase, NetBoxModel):
|
|||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse('wireless:wirelesslink', args=[self.pk])
|
return reverse('wireless:wirelesslink', args=[self.pk])
|
||||||
|
|
||||||
|
def get_status_color(self):
|
||||||
|
return LinkStatusChoices.colors.get(self.status)
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
|
|
||||||
# Validate interface types
|
# Validate interface types
|
||||||
|
Loading…
Reference in New Issue
Block a user