Skip to content

Commit

Permalink
10655 fix contacts display in list views (#10681)
Browse files Browse the repository at this point in the history
* 10655 fix contacts display in list views

* 10655 review changes
  • Loading branch information
arthanson authored Oct 18, 2022
1 parent 64d67e3 commit 2fe8df3
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 78 deletions.
10 changes: 4 additions & 6 deletions netbox/circuits/tables/circuits.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import django_tables2 as tables

from circuits.models import *
from tenancy.tables import ContactsColumnMixin, TenancyColumnsMixin

from netbox.tables import NetBoxTable, columns
from tenancy.tables import TenancyColumnsMixin

from .columns import CommitRateColumn

__all__ = (
Expand Down Expand Up @@ -39,7 +40,7 @@ class Meta(NetBoxTable.Meta):
default_columns = ('pk', 'name', 'circuit_count', 'description', 'slug')


class CircuitTable(TenancyColumnsMixin, NetBoxTable):
class CircuitTable(TenancyColumnsMixin, ContactsColumnMixin, NetBoxTable):
cid = tables.Column(
linkify=True,
verbose_name='Circuit ID'
Expand All @@ -58,9 +59,6 @@ class CircuitTable(TenancyColumnsMixin, NetBoxTable):
)
commit_rate = CommitRateColumn()
comments = columns.MarkdownColumn()
contacts = columns.ManyToManyColumn(
linkify_item=True
)
tags = columns.TagColumn(
url_name='circuits:circuit_list'
)
Expand Down
8 changes: 3 additions & 5 deletions netbox/circuits/tables/providers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import django_tables2 as tables
from circuits.models import *
from django_tables2.utils import Accessor
from tenancy.tables import ContactsColumnMixin

from circuits.models import *
from netbox.tables import NetBoxTable, columns

__all__ = (
Expand All @@ -10,7 +11,7 @@
)


class ProviderTable(NetBoxTable):
class ProviderTable(ContactsColumnMixin, NetBoxTable):
name = tables.Column(
linkify=True
)
Expand All @@ -31,9 +32,6 @@ class ProviderTable(NetBoxTable):
verbose_name='Circuits'
)
comments = columns.MarkdownColumn()
contacts = columns.ManyToManyColumn(
linkify_item=True
)
tags = columns.TagColumn(
url_name='circuits:provider_list'
)
Expand Down
29 changes: 20 additions & 9 deletions netbox/dcim/tables/devices.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
import django_tables2 as tables
from django_tables2.utils import Accessor

from dcim.models import (
ConsolePort, ConsoleServerPort, Device, DeviceBay, DeviceRole, FrontPort, Interface, InventoryItem,
InventoryItemRole, ModuleBay, Platform, PowerOutlet, PowerPort, RearPort, VirtualChassis,
ConsolePort,
ConsoleServerPort,
Device,
DeviceBay,
DeviceRole,
FrontPort,
Interface,
InventoryItem,
InventoryItemRole,
ModuleBay,
Platform,
PowerOutlet,
PowerPort,
RearPort,
VirtualChassis,
)
from django_tables2.utils import Accessor
from tenancy.tables import ContactsColumnMixin, TenancyColumnsMixin

from netbox.tables import NetBoxTable, columns
from tenancy.tables import TenancyColumnsMixin

from .template_code import *

__all__ = (
Expand Down Expand Up @@ -137,7 +151,7 @@ class Meta(NetBoxTable.Meta):
# Devices
#

class DeviceTable(TenancyColumnsMixin, NetBoxTable):
class DeviceTable(TenancyColumnsMixin, ContactsColumnMixin, NetBoxTable):
name = tables.TemplateColumn(
order_by=('_name',),
template_code=DEVICE_LINK
Expand Down Expand Up @@ -201,9 +215,6 @@ class DeviceTable(TenancyColumnsMixin, NetBoxTable):
verbose_name='VC Priority'
)
comments = columns.MarkdownColumn()
contacts = columns.ManyToManyColumn(
linkify_item=True
)
tags = columns.TagColumn(
url_name='dcim:device_list'
)
Expand Down
23 changes: 16 additions & 7 deletions netbox/dcim/tables/devicetypes.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
import django_tables2 as tables

from dcim.models import (
ConsolePortTemplate, ConsoleServerPortTemplate, DeviceBayTemplate, DeviceType, FrontPortTemplate, InterfaceTemplate,
InventoryItemTemplate, Manufacturer, ModuleBayTemplate, PowerOutletTemplate, PowerPortTemplate, RearPortTemplate,
ConsolePortTemplate,
ConsoleServerPortTemplate,
DeviceBayTemplate,
DeviceType,
FrontPortTemplate,
InterfaceTemplate,
InventoryItemTemplate,
Manufacturer,
ModuleBayTemplate,
PowerOutletTemplate,
PowerPortTemplate,
RearPortTemplate,
)
from tenancy.tables import ContactsColumnMixin

from netbox.tables import NetBoxTable, columns

from .template_code import MODULAR_COMPONENT_TEMPLATE_BUTTONS

__all__ = (
Expand All @@ -27,7 +39,7 @@
# Manufacturers
#

class ManufacturerTable(NetBoxTable):
class ManufacturerTable(ContactsColumnMixin, NetBoxTable):
name = tables.Column(
linkify=True
)
Expand All @@ -43,9 +55,6 @@ class ManufacturerTable(NetBoxTable):
verbose_name='Platforms'
)
slug = tables.Column()
contacts = columns.ManyToManyColumn(
linkify_item=True
)
tags = columns.TagColumn(
url_name='dcim:manufacturer_list'
)
Expand Down
9 changes: 4 additions & 5 deletions netbox/dcim/tables/power.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import django_tables2 as tables

from dcim.models import PowerFeed, PowerPanel
from tenancy.tables import ContactsColumnMixin

from netbox.tables import NetBoxTable, columns

from .devices import CableTerminationTable

__all__ = (
Expand All @@ -14,7 +16,7 @@
# Power panels
#

class PowerPanelTable(NetBoxTable):
class PowerPanelTable(ContactsColumnMixin, NetBoxTable):
name = tables.Column(
linkify=True
)
Expand All @@ -29,9 +31,6 @@ class PowerPanelTable(NetBoxTable):
url_params={'power_panel_id': 'pk'},
verbose_name='Feeds'
)
contacts = columns.ManyToManyColumn(
linkify_item=True
)
tags = columns.TagColumn(
url_name='dcim:powerpanel_list'
)
Expand Down
9 changes: 3 additions & 6 deletions netbox/dcim/tables/racks.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import django_tables2 as tables
from dcim.models import Rack, RackReservation, RackRole
from django_tables2.utils import Accessor
from tenancy.tables import ContactsColumnMixin, TenancyColumnsMixin

from dcim.models import Rack, RackReservation, RackRole
from netbox.tables import NetBoxTable, columns
from tenancy.tables import TenancyColumnsMixin

__all__ = (
'RackTable',
Expand Down Expand Up @@ -37,7 +37,7 @@ class Meta(NetBoxTable.Meta):
# Racks
#

class RackTable(TenancyColumnsMixin, NetBoxTable):
class RackTable(TenancyColumnsMixin, ContactsColumnMixin, NetBoxTable):
name = tables.Column(
order_by=('_name',),
linkify=True
Expand Down Expand Up @@ -68,9 +68,6 @@ class RackTable(TenancyColumnsMixin, NetBoxTable):
orderable=False,
verbose_name='Power'
)
contacts = columns.ManyToManyColumn(
linkify_item=True
)
tags = columns.TagColumn(
url_name='dcim:rack_list'
)
Expand Down
25 changes: 7 additions & 18 deletions netbox/dcim/tables/sites.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import django_tables2 as tables

from dcim.models import Location, Region, Site, SiteGroup
from tenancy.tables import ContactsColumnMixin, TenancyColumnsMixin

from netbox.tables import NetBoxTable, columns
from tenancy.tables import TenancyColumnsMixin

from .template_code import LOCATION_BUTTONS

__all__ = (
Expand All @@ -17,7 +18,7 @@
# Regions
#

class RegionTable(NetBoxTable):
class RegionTable(ContactsColumnMixin, NetBoxTable):
name = columns.MPTTColumn(
linkify=True
)
Expand All @@ -26,9 +27,6 @@ class RegionTable(NetBoxTable):
url_params={'region_id': 'pk'},
verbose_name='Sites'
)
contacts = columns.ManyToManyColumn(
linkify_item=True
)
tags = columns.TagColumn(
url_name='dcim:region_list'
)
Expand All @@ -46,7 +44,7 @@ class Meta(NetBoxTable.Meta):
# Site groups
#

class SiteGroupTable(NetBoxTable):
class SiteGroupTable(ContactsColumnMixin, NetBoxTable):
name = columns.MPTTColumn(
linkify=True
)
Expand All @@ -55,9 +53,6 @@ class SiteGroupTable(NetBoxTable):
url_params={'group_id': 'pk'},
verbose_name='Sites'
)
contacts = columns.ManyToManyColumn(
linkify_item=True
)
tags = columns.TagColumn(
url_name='dcim:sitegroup_list'
)
Expand All @@ -75,7 +70,7 @@ class Meta(NetBoxTable.Meta):
# Sites
#

class SiteTable(TenancyColumnsMixin, NetBoxTable):
class SiteTable(TenancyColumnsMixin, ContactsColumnMixin, NetBoxTable):
name = tables.Column(
linkify=True
)
Expand All @@ -97,9 +92,6 @@ class SiteTable(TenancyColumnsMixin, NetBoxTable):
verbose_name='ASN Count'
)
comments = columns.MarkdownColumn()
contacts = columns.ManyToManyColumn(
linkify_item=True
)
tags = columns.TagColumn(
url_name='dcim:site_list'
)
Expand All @@ -118,7 +110,7 @@ class Meta(NetBoxTable.Meta):
# Locations
#

class LocationTable(TenancyColumnsMixin, NetBoxTable):
class LocationTable(TenancyColumnsMixin, ContactsColumnMixin, NetBoxTable):
name = columns.MPTTColumn(
linkify=True
)
Expand All @@ -136,9 +128,6 @@ class LocationTable(TenancyColumnsMixin, NetBoxTable):
url_params={'location_id': 'pk'},
verbose_name='Devices'
)
contacts = columns.ManyToManyColumn(
linkify_item=True
)
tags = columns.TagColumn(
url_name='dcim:location_list'
)
Expand Down
10 changes: 10 additions & 0 deletions netbox/tenancy/tables/columns.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import django_tables2 as tables

from netbox.tables import columns

__all__ = (
'ContactsColumnMixin',
'TenantColumn',
'TenantGroupColumn',
'TenancyColumnsMixin',
Expand Down Expand Up @@ -55,3 +58,10 @@ def value(self, value):
class TenancyColumnsMixin(tables.Table):
tenant_group = TenantGroupColumn()
tenant = TenantColumn()


class ContactsColumnMixin(tables.Table):
contacts = columns.ManyToManyColumn(
linkify_item=True,
transform=lambda obj: obj.contact.name
)
8 changes: 3 additions & 5 deletions netbox/tenancy/tables/tenants.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import django_tables2 as tables
from tenancy.models import *
from tenancy.tables import ContactsColumnMixin

from netbox.tables import NetBoxTable, columns
from tenancy.models import *

__all__ = (
'TenantGroupTable',
Expand Down Expand Up @@ -30,17 +31,14 @@ class Meta(NetBoxTable.Meta):
default_columns = ('pk', 'name', 'tenant_count', 'description')


class TenantTable(NetBoxTable):
class TenantTable(ContactsColumnMixin, NetBoxTable):
name = tables.Column(
linkify=True
)
group = tables.Column(
linkify=True
)
comments = columns.MarkdownColumn()
contacts = columns.ManyToManyColumn(
linkify_item=True
)
tags = columns.TagColumn(
url_name='tenancy:contact_list'
)
Expand Down
Loading

0 comments on commit 2fe8df3

Please sign in to comment.