From 20ec9453c216fd999eec312312465558c32419f7 Mon Sep 17 00:00:00 2001 From: Louis Date: Thu, 17 Sep 2026 15:27:34 +0200 Subject: [PATCH] feat: support netbox-export 0.3.14 and netbox-reorder-rack 1.1.5 Verified against the actually installed versions that the patched hook signatures (serialize_object, is_exportable_model, _defer_device_placement, _device_placement_conflicts, _apply_device_placements, SaveViewSet.update, ReorderView.get) are still compatible with our wrappers, then added both versions to the supported sets so the width-aware patches stop being silently skipped. netbox-reorder-rack 1.1.5 changed ReorderView.get from (self, request, pk) to (self, request, **kwargs). Our fallback path called the original view with a positional pk, which would now raise TypeError; width_aware_reorder_get now accepts pk as a keyword with **kwargs passthrough so both the patched and native code paths work regardless of which signature is installed. Co-Authored-By: Claude Sonnet 5 --- netbox_utilities/__init__.py | 2 +- netbox_utilities/netbox_export.py | 2 +- netbox_utilities/reorder_rack.py | 6 ++--- netbox_utilities/tests/test_reorder_rack.py | 25 +++++++++++++++++++++ pyproject.toml | 2 +- 5 files changed, 31 insertions(+), 6 deletions(-) diff --git a/netbox_utilities/__init__.py b/netbox_utilities/__init__.py index 6a625e6..dbf66d0 100644 --- a/netbox_utilities/__init__.py +++ b/netbox_utilities/__init__.py @@ -1,6 +1,6 @@ from netbox.plugins import PluginConfig, get_plugin_config -__version__ = "0.11.3" +__version__ = "0.11.4" class NetBoxUtilitiesConfig(PluginConfig): diff --git a/netbox_utilities/netbox_export.py b/netbox_utilities/netbox_export.py index 9fc12e7..975b9db 100644 --- a/netbox_utilities/netbox_export.py +++ b/netbox_utilities/netbox_export.py @@ -18,7 +18,7 @@ from .rack_width import ( logger = logging.getLogger(__name__) -SUPPORTED_NETBOX_EXPORT_VERSIONS = {"0.3.11"} +SUPPORTED_NETBOX_EXPORT_VERSIONS = {"0.3.11", "0.3.14"} RACK_WIDTH_RECORD_KEY = "netbox_utilities_rack_placement" PATCH_MARKER = "_netbox_utilities_rack_width_version" PATCH_VERSION = 1 diff --git a/netbox_utilities/reorder_rack.py b/netbox_utilities/reorder_rack.py index 6ef73c7..886c6b0 100644 --- a/netbox_utilities/reorder_rack.py +++ b/netbox_utilities/reorder_rack.py @@ -21,7 +21,7 @@ from .rack_width import FULL_WIDTH, effective_width_positions, normalize_width_p logger = logging.getLogger(__name__) -SUPPORTED_REORDER_RACK_VERSIONS = {"1.1.4"} +SUPPORTED_REORDER_RACK_VERSIONS = {"1.1.4", "1.1.5"} PATCH_MARKER = "_netbox_utilities_bulk_save" VIEW_PATCH_MARKER = "_netbox_utilities_width_aware_view" GRID_COLUMNS = 12 @@ -402,7 +402,7 @@ def bulk_reorder_update(self, request, pk=None): ) -def width_aware_reorder_get(self, request, pk): +def width_aware_reorder_get(self, request, pk=None, **kwargs): """Render every rack device server-side on the native Reorder page.""" from dcim.choices import SubdeviceRoleChoices from django.conf import settings @@ -436,7 +436,7 @@ def width_aware_reorder_get(self, request, pk): if not width_data or not width_data.get("complete"): original_get = getattr(type(self), "_netbox_utilities_original_get", None) if original_get is not None: - return original_get(self, request, pk) + return original_get(self, request, pk=pk, **kwargs) raise Http404 return render( diff --git a/netbox_utilities/tests/test_reorder_rack.py b/netbox_utilities/tests/test_reorder_rack.py index 75aaa02..8ee5f47 100644 --- a/netbox_utilities/tests/test_reorder_rack.py +++ b/netbox_utilities/tests/test_reorder_rack.py @@ -654,6 +654,31 @@ class ReorderRackPatchTest(SimpleTestCase): self.assertIs(ReorderView.get, width_aware_reorder_get) self.assertIs(ReorderView._netbox_utilities_original_get, original_get) + def test_falls_back_to_original_get_with_keyword_pk_and_extra_kwargs(self): + """netbox-reorder-rack 1.1.5 changed ReorderView.get to (self, request, **kwargs).""" + calls = [] + + def original_get(self, request, **kwargs): + calls.append(kwargs) + return "native-response" + + class ReorderView: + get = original_get + + ReorderView._netbox_utilities_original_get = original_get + + with ( + patch("netbox_utilities.reorder_rack.get_object_or_404", return_value=SimpleNamespace(pk=3)), + patch("netbox_utilities.reorder_rack.Device") as device_model, + patch("netbox_utilities.reorder_rack.get_reorder_rack_width_data", return_value=None), + ): + device_model.objects.filter.return_value.exclude.return_value.select_related.return_value = [] + device_model.objects.filter.return_value.select_related.return_value.order_by.return_value = [] + result = width_aware_reorder_get(ReorderView(), MagicMock(), pk=3, extra="value") + + self.assertEqual(result, "native-response") + self.assertEqual(calls, [{"pk": 3, "extra": "value"}]) + def test_skips_unsupported_plugin_version(self): with ( patch("netbox_utilities.reorder_rack.apps.is_installed", return_value=True), diff --git a/pyproject.toml b/pyproject.toml index fa14bae..03b999d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "netbox-utilities" -version = "0.11.3" +version = "0.11.4" description = "Navigation, tenant utilities, connection VLANs, partial-width racks, and bulk operations for NetBox 4.6/4.7" readme = "README.md" requires-python = ">=3.12"