Fixes #19610: FieldError when sorting Tunnel Termination on tenant (#19612)

This commit is contained in:
Jason Novinger 2025-06-04 15:50:12 -05:00 committed by GitHub
parent 5fe5b2e7c4
commit e24fa2ee4d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 1 deletions

View File

@ -73,7 +73,7 @@ class TunnelTable(TenancyColumnsMixin, NetBoxTable):
default_columns = ('pk', 'name', 'group', 'status', 'encapsulation', 'tenant', 'terminations_count') default_columns = ('pk', 'name', 'group', 'status', 'encapsulation', 'tenant', 'terminations_count')
class TunnelTerminationTable(TenancyColumnsMixin, NetBoxTable): class TunnelTerminationTable(NetBoxTable):
tunnel = tables.Column( tunnel = tables.Column(
verbose_name=_('Tunnel'), verbose_name=_('Tunnel'),
linkify=True linkify=True

View File

@ -0,0 +1,23 @@
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'}
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)