From ec098da4b94bee3c68d49141ebc7bee9fc41e22c Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Mon, 23 Oct 2023 15:35:04 -0400 Subject: [PATCH] Fix backend type display in table column --- netbox/core/tables/columns.py | 20 ++++++++++++++++++++ netbox/core/tables/data.py | 4 ++++ 2 files changed, 24 insertions(+) create mode 100644 netbox/core/tables/columns.py diff --git a/netbox/core/tables/columns.py b/netbox/core/tables/columns.py new file mode 100644 index 000000000..93f1e3901 --- /dev/null +++ b/netbox/core/tables/columns.py @@ -0,0 +1,20 @@ +import django_tables2 as tables + +from netbox.registry import registry + +__all__ = ( + 'BackendTypeColumn', +) + + +class BackendTypeColumn(tables.Column): + """ + Display a data backend type. + """ + def render(self, value): + if backend := registry['data_backends'].get(value): + return backend.label + return value + + def value(self, value): + return value diff --git a/netbox/core/tables/data.py b/netbox/core/tables/data.py index a1b608547..4059ea9bc 100644 --- a/netbox/core/tables/data.py +++ b/netbox/core/tables/data.py @@ -3,6 +3,7 @@ import django_tables2 as tables from core.models import * from netbox.tables import NetBoxTable, columns +from .columns import BackendTypeColumn __all__ = ( 'DataFileTable', @@ -15,6 +16,9 @@ class DataSourceTable(NetBoxTable): verbose_name=_('Name'), linkify=True ) + type = BackendTypeColumn( + verbose_name=_('Type') + ) status = columns.ChoiceFieldColumn( verbose_name=_('Status'), )