feat: make site prefix column sortable

Clicking the Prefix column header sorts device and rack lists by site
name, which starts with the prefix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-25 11:10:29 +02:00
co-authored by Claude Opus 5.5
parent 337cd28c23
commit c7b65f123b
3 changed files with 11 additions and 2 deletions
+2 -1
View File
@@ -104,7 +104,8 @@ def install_site_prefix_column():
accessor=tables.A("site"),
verbose_name="Prefix",
empty_values=(),
orderable=False,
# Der Standortname beginnt mit dem Prefix, sortiert also in derselben Reihenfolge.
order_by=("site__name",),
)
register_table_column(column, COLUMN_NAME, DeviceTable, RackTable)
prepend_to_default_columns(DeviceTable)
@@ -74,5 +74,9 @@ class SitePrefixTest(SimpleTestCase):
self.assertIn(COLUMN_NAME, DeviceTable.base_columns)
self.assertIn(COLUMN_NAME, RackTable.base_columns)
for table in (DeviceTable, RackTable):
column = table.base_columns[COLUMN_NAME]
self.assertTrue(column.orderable)
self.assertEqual(tuple(column.order_by), ("site__name",))
self.assertEqual(DeviceTable.Meta.default_columns[:2], ("pk", COLUMN_NAME))
self.assertEqual(RackTable.Meta.default_columns[:2], ("pk", COLUMN_NAME))