mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
* Initial work on #13381 * Fix backend type display in table column * Fix data source type choices during bulk edit * Misc cleanup * Move backend utils from core app to netbox * Move backend type validation from serializer to model
66 lines
1.7 KiB
Python
66 lines
1.7 KiB
Python
from django.utils.translation import gettext_lazy as _
|
|
import django_tables2 as tables
|
|
|
|
from core.models import *
|
|
from netbox.tables import NetBoxTable, columns
|
|
from .columns import BackendTypeColumn
|
|
|
|
__all__ = (
|
|
'DataFileTable',
|
|
'DataSourceTable',
|
|
)
|
|
|
|
|
|
class DataSourceTable(NetBoxTable):
|
|
name = tables.Column(
|
|
verbose_name=_('Name'),
|
|
linkify=True
|
|
)
|
|
type = BackendTypeColumn(
|
|
verbose_name=_('Type')
|
|
)
|
|
status = columns.ChoiceFieldColumn(
|
|
verbose_name=_('Status'),
|
|
)
|
|
enabled = columns.BooleanColumn(
|
|
verbose_name=_('Enabled'),
|
|
)
|
|
tags = columns.TagColumn(
|
|
url_name='core:datasource_list'
|
|
)
|
|
file_count = tables.Column(
|
|
verbose_name='Files'
|
|
)
|
|
|
|
class Meta(NetBoxTable.Meta):
|
|
model = DataSource
|
|
fields = (
|
|
'pk', 'id', 'name', 'type', 'status', 'enabled', 'source_url', 'description', 'comments', 'parameters',
|
|
'created', 'last_updated', 'file_count',
|
|
)
|
|
default_columns = ('pk', 'name', 'type', 'status', 'enabled', 'description', 'file_count')
|
|
|
|
|
|
class DataFileTable(NetBoxTable):
|
|
source = tables.Column(
|
|
verbose_name=_('Source'),
|
|
linkify=True
|
|
)
|
|
path = tables.Column(
|
|
verbose_name=_('Path'),
|
|
linkify=True
|
|
)
|
|
last_updated = columns.DateTimeColumn(
|
|
verbose_name=_('Last updated'),
|
|
)
|
|
actions = columns.ActionsColumn(
|
|
actions=('delete',)
|
|
)
|
|
|
|
class Meta(NetBoxTable.Meta):
|
|
model = DataFile
|
|
fields = (
|
|
'pk', 'id', 'source', 'path', 'last_updated', 'size', 'hash',
|
|
)
|
|
default_columns = ('pk', 'source', 'path', 'size', 'last_updated')
|