From 9c2d55d68200d6b953c70fe2aaa892d10ee30de2 Mon Sep 17 00:00:00 2001 From: Jathn Date: Wed, 30 Jul 2025 18:11:48 +0300 Subject: [PATCH] Closes #18843: use color name in cable export --- netbox/dcim/models/cables.py | 10 ++++++++++ netbox/dcim/tables/cables.py | 3 +++ 2 files changed, 13 insertions(+) diff --git a/netbox/dcim/models/cables.py b/netbox/dcim/models/cables.py index 0a28d5acb..26bb0fed7 100644 --- a/netbox/dcim/models/cables.py +++ b/netbox/dcim/models/cables.py @@ -11,6 +11,7 @@ from dcim.choices import * from dcim.constants import * from dcim.fields import PathField from dcim.utils import decompile_path_node, object_to_path_node +from netbox.choices import ColorChoices from netbox.models import ChangeLoggedModel, PrimaryModel from utilities.conversion import to_meters from utilities.exceptions import AbortRequest @@ -155,6 +156,15 @@ class Cable(PrimaryModel): self._terminations_modified = True self._b_terminations = value + @property + def color_name(self): + color_name = "" + for hex_code, label in ColorChoices.CHOICES: + if hex_code.lower() == self.color.lower(): + color_name = str(label) + + return color_name + def clean(self): super().clean() diff --git a/netbox/dcim/tables/cables.py b/netbox/dcim/tables/cables.py index e12545fd2..63887154e 100644 --- a/netbox/dcim/tables/cables.py +++ b/netbox/dcim/tables/cables.py @@ -113,6 +113,9 @@ class CableTable(TenancyColumnsMixin, NetBoxTable): order_by=('_abs_length') ) color = columns.ColorColumn() + color_name = tables.Column( + verbose_name=_('Color Name') + ) comments = columns.MarkdownColumn() tags = columns.TagColumn( url_name='dcim:cable_list'