From 05453805435805f3cf1a49977c9c2c732474e052 Mon Sep 17 00:00:00 2001 From: iamjohnnymac <33052970+iamjohnnymac@users.noreply.github.com> Date: Tue, 19 May 2026 08:51:38 +0800 Subject: [PATCH] fix: add get_color_color() to Strand + Tube so TIA-598 badges render in their actual colour (v0.3.5) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit v0.3.4 added CSS overrides for text-bg-blue/black/white but they had no effect. Root cause: NetBox's ChoiceFieldColumn (and the badge template tag) look up the colour by calling get__color() on the model — neither Strand nor Tube defined that method, so every strand colour rendered as text-bg-secondary (grey). Two-line fix per model: return TIA598ColorChoices.colors.get(self.color). Blue now renders blue, Orange orange, Brown brown, etc. — strand colour codes are functionally identifiable at a glance again. --- CHANGELOG.md | 17 ++++++++++++++++- netbox_osp/__init__.py | 2 +- netbox_osp/models/cables.py | 12 ++++++++++++ pyproject.toml | 2 +- 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3813719..2d14535 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,20 @@ Per-release NetBox / Python compatibility lives in ## [Unreleased] +## [0.3.5] — 2026-05-19 + +### Fixed + +- **TIA-598 strand colour badges now actually use their named colour.** + v0.3.4 added CSS overrides for `text-bg-blue` / `text-bg-black` / + `text-bg-white` — but they had no effect because NetBox's + `ChoiceFieldColumn` was rendering every TIA-598 colour as + `text-bg-secondary` (grey). Root cause: neither `Strand` nor `Tube` + defined a `get_color_color()` method, so the column couldn't look + up the badge colour from `TIA598ColorChoices`. Added the helper on + both models — colour codes now render in their actual colour + (Blue is blue, Orange is orange, Brown is brown, etc.). + ## [0.3.4] — 2026-05-19 ### Fixed @@ -387,7 +401,8 @@ GPS markers. - PyPI name-reservation placeholder. Not functional. -[Unreleased]: https://github.com/iamjohnnymac/netbox-osp/compare/v0.3.4...HEAD +[Unreleased]: https://github.com/iamjohnnymac/netbox-osp/compare/v0.3.5...HEAD +[0.3.5]: https://github.com/iamjohnnymac/netbox-osp/releases/tag/v0.3.5 [0.3.4]: https://github.com/iamjohnnymac/netbox-osp/releases/tag/v0.3.4 [0.3.3]: https://github.com/iamjohnnymac/netbox-osp/releases/tag/v0.3.3 [0.3.2]: https://github.com/iamjohnnymac/netbox-osp/releases/tag/v0.3.2 diff --git a/netbox_osp/__init__.py b/netbox_osp/__init__.py index 0440f1d..f1515a1 100644 --- a/netbox_osp/__init__.py +++ b/netbox_osp/__init__.py @@ -5,7 +5,7 @@ class NetBoxOspConfig(PluginConfig): name = "netbox_osp" verbose_name = "NetBox OSP" description = "Outside-plant fibre management — cables, splice closures, fibre links with loss budgets, and an offline-capable Leaflet plant map." - version = "0.3.4" + version = "0.3.5" author = "John McKean" author_email = "33052970+iamjohnnymac@users.noreply.github.com" base_url = "osp" diff --git a/netbox_osp/models/cables.py b/netbox_osp/models/cables.py index cb5eff8..a69a573 100644 --- a/netbox_osp/models/cables.py +++ b/netbox_osp/models/cables.py @@ -179,6 +179,12 @@ def __str__(self): def get_absolute_url(self): return reverse("plugins:netbox_osp:tube", args=[self.pk]) + def get_color_color(self): + """NetBox's ChoiceFieldColumn looks up the badge colour by calling + get__color() on the model. Without this, the colour column + renders every value as `text-bg-secondary` (grey).""" + return TIA598ColorChoices.colors.get(self.color) + def save(self, *args, **kwargs): if not self.color: self.color = TIA598ColorChoices.for_position(self.number or 1) @@ -238,6 +244,12 @@ def get_absolute_url(self): def get_status_color(self): return StrandStatusChoices.colors.get(self.status) + def get_color_color(self): + """ChoiceFieldColumn / badge template tag both look up the badge + colour by calling get__color() on the model. Without this, + the strand colour code renders as `text-bg-secondary` (grey).""" + return TIA598ColorChoices.colors.get(self.color) + def save(self, *args, **kwargs): if not self.color: self.color = TIA598ColorChoices.for_position(self.position or 1) diff --git a/pyproject.toml b/pyproject.toml index e4bf01a..2cc27a0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "netbox-osp" -version = "0.3.4" +version = "0.3.5" description = "Outside-plant fibre management for NetBox — cables, splice closures, fibre links with loss budgets, and an offline-capable Leaflet plant map." authors = [{ name = "John McKean", email = "33052970+iamjohnnymac@users.noreply.github.com" }] maintainers = [{ name = "John McKean", email = "33052970+iamjohnnymac@users.noreply.github.com" }]