mirror of
https://github.com/netbox-community/netbox.git
synced 2025-12-09 01:49:35 -06:00
Enhance `ServiceTable` by incorporating `ContactsColumnMixin` for better contact management. Updates the fields to include `contacts`. Fixes #20567
68 lines
1.9 KiB
Python
68 lines
1.9 KiB
Python
from django.utils.translation import gettext_lazy as _
|
|
import django_tables2 as tables
|
|
|
|
from ipam.models import *
|
|
from netbox.tables import NetBoxTable, columns
|
|
from tenancy.tables import ContactsColumnMixin
|
|
|
|
__all__ = (
|
|
'ServiceTable',
|
|
'ServiceTemplateTable',
|
|
)
|
|
|
|
|
|
class ServiceTemplateTable(NetBoxTable):
|
|
name = tables.Column(
|
|
verbose_name=_('Name'),
|
|
linkify=True
|
|
)
|
|
ports = tables.Column(
|
|
verbose_name=_('Ports'),
|
|
accessor=tables.A('port_list'),
|
|
order_by=tables.A('ports'),
|
|
)
|
|
comments = columns.MarkdownColumn(
|
|
verbose_name=_('Comments'),
|
|
)
|
|
tags = columns.TagColumn(
|
|
url_name='ipam:servicetemplate_list'
|
|
)
|
|
|
|
class Meta(NetBoxTable.Meta):
|
|
model = ServiceTemplate
|
|
fields = (
|
|
'pk', 'id', 'name', 'protocol', 'ports', 'description', 'comments', 'tags', 'created', 'last_updated',
|
|
)
|
|
default_columns = ('pk', 'name', 'protocol', 'ports', 'description')
|
|
|
|
|
|
class ServiceTable(ContactsColumnMixin, NetBoxTable):
|
|
name = tables.Column(
|
|
verbose_name=_('Name'),
|
|
linkify=True
|
|
)
|
|
parent = tables.Column(
|
|
verbose_name=_('Parent'),
|
|
linkify=True,
|
|
order_by=('device', 'virtual_machine')
|
|
)
|
|
ports = tables.Column(
|
|
verbose_name=_('Ports'),
|
|
accessor=tables.A('port_list'),
|
|
order_by=tables.A('ports'),
|
|
)
|
|
comments = columns.MarkdownColumn(
|
|
verbose_name=_('Comments'),
|
|
)
|
|
tags = columns.TagColumn(
|
|
url_name='ipam:service_list'
|
|
)
|
|
|
|
class Meta(NetBoxTable.Meta):
|
|
model = Service
|
|
fields = (
|
|
'pk', 'id', 'name', 'parent', 'protocol', 'ports', 'ipaddresses', 'description', 'contacts', 'comments',
|
|
'tags', 'created', 'last_updated',
|
|
)
|
|
default_columns = ('pk', 'name', 'parent', 'protocol', 'ports', 'description')
|