2016-07-26 14:58:37 -04:00
|
|
|
import django_tables2 as tables
|
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
from netbox.tables import NetBoxTable, columns
|
2022-03-03 15:16:23 -05:00
|
|
|
from tenancy.models import *
|
2022-01-27 15:00:10 -05:00
|
|
|
from utilities.tables import linkify_phone
|
2016-07-26 14:58:37 -04:00
|
|
|
|
2021-09-17 15:37:19 -04:00
|
|
|
__all__ = (
|
2021-10-18 11:45:05 -04:00
|
|
|
'ContactAssignmentTable',
|
|
|
|
'ContactGroupTable',
|
|
|
|
'ContactRoleTable',
|
|
|
|
'ContactTable',
|
2021-09-17 15:37:19 -04:00
|
|
|
)
|
|
|
|
|
2021-03-04 16:07:55 -05:00
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
class ContactGroupTable(NetBoxTable):
|
2022-01-27 15:00:10 -05:00
|
|
|
name = columns.MPTTColumn(
|
2021-10-18 11:45:05 -04:00
|
|
|
linkify=True
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
contact_count = columns.LinkedCountColumn(
|
2021-10-18 11:45:05 -04:00
|
|
|
viewname='tenancy:contact_list',
|
|
|
|
url_params={'role_id': 'pk'},
|
|
|
|
verbose_name='Contacts'
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
tags = columns.TagColumn(
|
2021-10-21 10:51:02 -04:00
|
|
|
url_name='tenancy:contactgroup_list'
|
|
|
|
)
|
2021-10-18 11:45:05 -04:00
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
class Meta(NetBoxTable.Meta):
|
2021-10-18 11:45:05 -04:00
|
|
|
model = ContactGroup
|
2022-01-17 11:12:54 -05:00
|
|
|
fields = (
|
|
|
|
'pk', 'name', 'contact_count', 'description', 'slug', 'tags', 'created', 'last_updated', 'actions',
|
|
|
|
)
|
2022-01-07 10:36:58 -05:00
|
|
|
default_columns = ('pk', 'name', 'contact_count', 'description')
|
2021-10-18 11:45:05 -04:00
|
|
|
|
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
class ContactRoleTable(NetBoxTable):
|
2021-10-18 11:45:05 -04:00
|
|
|
name = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
class Meta(NetBoxTable.Meta):
|
2021-10-18 11:45:05 -04:00
|
|
|
model = ContactRole
|
2022-01-17 11:12:54 -05:00
|
|
|
fields = ('pk', 'name', 'description', 'slug', 'created', 'last_updated', 'actions')
|
2022-01-07 10:36:58 -05:00
|
|
|
default_columns = ('pk', 'name', 'description')
|
2021-10-18 11:45:05 -04:00
|
|
|
|
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
class ContactTable(NetBoxTable):
|
2021-10-18 11:45:05 -04:00
|
|
|
name = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
|
|
|
group = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
2021-12-03 10:51:24 -05:00
|
|
|
phone = tables.Column(
|
|
|
|
linkify=linkify_phone,
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
comments = columns.MarkdownColumn()
|
2021-10-18 15:30:28 -04:00
|
|
|
assignment_count = tables.Column(
|
|
|
|
verbose_name='Assignments'
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
tags = columns.TagColumn(
|
2021-10-18 11:45:05 -04:00
|
|
|
url_name='tenancy:tenant_list'
|
|
|
|
)
|
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
class Meta(NetBoxTable.Meta):
|
2021-10-18 11:45:05 -04:00
|
|
|
model = Contact
|
2022-01-17 11:12:54 -05:00
|
|
|
fields = (
|
|
|
|
'pk', 'name', 'group', 'title', 'phone', 'email', 'address', 'comments', 'assignment_count', 'tags',
|
|
|
|
'created', 'last_updated',
|
|
|
|
)
|
2021-10-18 15:30:28 -04:00
|
|
|
default_columns = ('pk', 'name', 'group', 'assignment_count', 'title', 'phone', 'email')
|
2021-10-18 11:45:05 -04:00
|
|
|
|
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
class ContactAssignmentTable(NetBoxTable):
|
2022-01-27 15:00:10 -05:00
|
|
|
content_type = columns.ContentTypeColumn(
|
2021-10-18 15:30:28 -04:00
|
|
|
verbose_name='Object Type'
|
|
|
|
)
|
|
|
|
object = tables.Column(
|
|
|
|
linkify=True,
|
|
|
|
orderable=False
|
|
|
|
)
|
2021-10-18 11:45:05 -04:00
|
|
|
contact = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
2021-10-18 15:30:28 -04:00
|
|
|
role = tables.Column(
|
|
|
|
linkify=True
|
|
|
|
)
|
2022-01-27 15:00:10 -05:00
|
|
|
actions = columns.ActionsColumn(
|
2022-01-07 11:56:18 -05:00
|
|
|
sequence=('edit', 'delete')
|
2021-11-04 14:01:07 -04:00
|
|
|
)
|
2021-10-18 11:45:05 -04:00
|
|
|
|
2022-01-27 15:48:05 -05:00
|
|
|
class Meta(NetBoxTable.Meta):
|
2021-10-18 11:45:05 -04:00
|
|
|
model = ContactAssignment
|
2021-11-04 14:01:07 -04:00
|
|
|
fields = ('pk', 'content_type', 'object', 'contact', 'role', 'priority', 'actions')
|
2022-01-07 10:36:58 -05:00
|
|
|
default_columns = ('pk', 'content_type', 'object', 'contact', 'role', 'priority')
|