mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-24 16:26:09 -06:00
use TemplateColumn instead of own class
This commit is contained in:
parent
59e657867c
commit
71f00850dc
@ -1,5 +1,4 @@
|
||||
from .cables import *
|
||||
from .columns import *
|
||||
from .connections import *
|
||||
from .devices import *
|
||||
from .devicetypes import *
|
||||
|
@ -1,21 +0,0 @@
|
||||
import django_tables2 as tables
|
||||
|
||||
__all__ = (
|
||||
'SpeedColumn',
|
||||
)
|
||||
|
||||
|
||||
class SpeedColumn(tables.TemplateColumn):
|
||||
"""
|
||||
Humanize the speed in the column view
|
||||
"""
|
||||
template_code = """
|
||||
{% load helpers %}
|
||||
{{ value|humanize_speed|placeholder }}
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(template_code=self.template_code, *args, **kwargs)
|
||||
|
||||
def value(self, value, **kwargs):
|
||||
return super().value(value=value, **kwargs) if value else None
|
@ -5,7 +5,6 @@ from tenancy.tables import ContactsColumnMixin, TenancyColumnsMixin
|
||||
|
||||
from netbox.tables import NetBoxTable, columns
|
||||
|
||||
from .columns import *
|
||||
from .template_code import *
|
||||
|
||||
__all__ = (
|
||||
@ -546,7 +545,8 @@ class InterfaceTable(ModularDeviceComponentTable, BaseInterfaceTable, PathEndpoi
|
||||
}
|
||||
)
|
||||
mgmt_only = columns.BooleanColumn()
|
||||
speed_formatted = SpeedColumn(
|
||||
speed_formatted = columns.TemplateColumn(
|
||||
template_code='{% load helpers %}{{ value|humanize_speed }}',
|
||||
accessor=Accessor('speed'),
|
||||
verbose_name='Speed'
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user