From ce90cb7becc6571e4b832e125c155bf4d8bf1bd0 Mon Sep 17 00:00:00 2001 From: Jason Novinger Date: Fri, 30 May 2025 12:39:25 -0500 Subject: [PATCH 1/3] Fixes #19610: FieldError when sorting Tunnel Termination on tenant It turns out that the TunnelTermination model doesn't implement the tenancy "protocol", in that there are no foreign keys to a tenant or tenant group. It looks like TenancyColumnsMixin was added to TunnelTerminationTable by mistake in completing #9816. --- netbox/vpn/tables/tunnels.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netbox/vpn/tables/tunnels.py b/netbox/vpn/tables/tunnels.py index d23317ac048..fc8dec5e47d 100644 --- a/netbox/vpn/tables/tunnels.py +++ b/netbox/vpn/tables/tunnels.py @@ -73,7 +73,7 @@ class Meta(NetBoxTable.Meta): default_columns = ('pk', 'name', 'group', 'status', 'encapsulation', 'tenant', 'terminations_count') -class TunnelTerminationTable(TenancyColumnsMixin, NetBoxTable): +class TunnelTerminationTable(NetBoxTable): tunnel = tables.Column( verbose_name=_('Tunnel'), linkify=True From 320261432ac75fd3cfc57f898a50acbb879a7c9e Mon Sep 17 00:00:00 2001 From: Jason Novinger Date: Fri, 30 May 2025 13:23:26 -0500 Subject: [PATCH 2/3] Add regression test for #19610 --- netbox/vpn/tests/test_tables.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 netbox/vpn/tests/test_tables.py diff --git a/netbox/vpn/tests/test_tables.py b/netbox/vpn/tests/test_tables.py new file mode 100644 index 00000000000..76248be5a97 --- /dev/null +++ b/netbox/vpn/tests/test_tables.py @@ -0,0 +1,26 @@ +from django.test import RequestFactory, tag, TestCase + +from vpn.models import TunnelTermination +from vpn.tables import TunnelTerminationTable + + +@tag('regression') +class TunnelTerminationTableTest(TestCase): + def test_every_orderable_field_does_not_throw_exception(self): + terminations = TunnelTermination.objects.all() + fake_request = RequestFactory().get("/") + disallowed = { + 'actions', + 'termination', # TODO: remove this when #19600 is merged + } + + orderable_columns = [ + column.name for column in TunnelTerminationTable(terminations).columns + if column.orderable and column.name not in disallowed + ] + + for col in orderable_columns: + for dir in ('-', ''): + table = TunnelTerminationTable(terminations) + table.order_by = f'{dir}{col}' + table.as_html(fake_request) From 269024ddae23de1b916625d47e305db784b1b853 Mon Sep 17 00:00:00 2001 From: Jason Novinger Date: Wed, 4 Jun 2025 11:56:55 -0500 Subject: [PATCH 3/3] Remove disallowed terminations field in table ordering test This is possible because #19487 was merged. --- netbox/vpn/tests/test_tables.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/netbox/vpn/tests/test_tables.py b/netbox/vpn/tests/test_tables.py index 76248be5a97..0c7a4ae808c 100644 --- a/netbox/vpn/tests/test_tables.py +++ b/netbox/vpn/tests/test_tables.py @@ -9,10 +9,7 @@ class TunnelTerminationTableTest(TestCase): def test_every_orderable_field_does_not_throw_exception(self): terminations = TunnelTermination.objects.all() fake_request = RequestFactory().get("/") - disallowed = { - 'actions', - 'termination', # TODO: remove this when #19600 is merged - } + disallowed = {'actions'} orderable_columns = [ column.name for column in TunnelTerminationTable(terminations).columns