mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-23 07:56:44 -06:00
Fix backend type display in table column
This commit is contained in:
parent
21d17d5891
commit
ec098da4b9
20
netbox/core/tables/columns.py
Normal file
20
netbox/core/tables/columns.py
Normal file
@ -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
|
@ -3,6 +3,7 @@ import django_tables2 as tables
|
|||||||
|
|
||||||
from core.models import *
|
from core.models import *
|
||||||
from netbox.tables import NetBoxTable, columns
|
from netbox.tables import NetBoxTable, columns
|
||||||
|
from .columns import BackendTypeColumn
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
'DataFileTable',
|
'DataFileTable',
|
||||||
@ -15,6 +16,9 @@ class DataSourceTable(NetBoxTable):
|
|||||||
verbose_name=_('Name'),
|
verbose_name=_('Name'),
|
||||||
linkify=True
|
linkify=True
|
||||||
)
|
)
|
||||||
|
type = BackendTypeColumn(
|
||||||
|
verbose_name=_('Type')
|
||||||
|
)
|
||||||
status = columns.ChoiceFieldColumn(
|
status = columns.ChoiceFieldColumn(
|
||||||
verbose_name=_('Status'),
|
verbose_name=_('Status'),
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user