Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions netbox/circuits/tables/circuits.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from circuits.models import *
from netbox.tables import NetBoxTable, columns
from tenancy.tables import TenantColumn
from tenancy.tables import TenancyColumnsMixin
from .columns import CommitRateColumn

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


class CircuitTable(NetBoxTable):
class CircuitTable(TenancyColumnsMixin, NetBoxTable):
cid = tables.Column(
linkify=True,
verbose_name='Circuit ID'
Expand All @@ -48,7 +48,6 @@ class CircuitTable(NetBoxTable):
linkify=True
)
status = columns.ChoiceFieldColumn()
tenant = TenantColumn()
termination_a = tables.TemplateColumn(
template_code=CIRCUITTERMINATION_LINK,
verbose_name='Side A'
Expand All @@ -69,7 +68,7 @@ class CircuitTable(NetBoxTable):
class Meta(NetBoxTable.Meta):
model = Circuit
fields = (
'pk', 'id', 'cid', 'provider', 'type', 'status', 'tenant', 'termination_a', 'termination_z', 'install_date',
'pk', 'id', 'cid', 'provider', 'type', 'status', 'tenant', 'tenant_group', 'termination_a', 'termination_z', 'install_date',
'commit_rate', 'description', 'comments', 'contacts', 'tags', 'created', 'last_updated',
)
default_columns = (
Expand Down
6 changes: 3 additions & 3 deletions netbox/circuits/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def get_extra_context(self, request, instance):
circuits = Circuit.objects.restrict(request.user, 'view').filter(
provider=instance
).prefetch_related(
'type', 'tenant', 'terminations__site'
'type', 'tenant', 'tenant__group', 'terminations__site'
)
circuits_table = tables.CircuitTable(circuits, user=request.user, exclude=('provider',))
circuits_table.configure(request)
Expand Down Expand Up @@ -91,7 +91,7 @@ def get_extra_context(self, request, instance):
Q(termination_a__provider_network=instance.pk) |
Q(termination_z__provider_network=instance.pk)
).prefetch_related(
'type', 'tenant', 'terminations__site'
'type', 'tenant', 'tenant__group', 'terminations__site'
)
circuits_table = tables.CircuitTable(circuits, user=request.user)
circuits_table.configure(request)
Expand Down Expand Up @@ -192,7 +192,7 @@ class CircuitTypeBulkDeleteView(generic.BulkDeleteView):

class CircuitListView(generic.ObjectListView):
queryset = Circuit.objects.prefetch_related(
'provider', 'type', 'tenant', 'termination_a', 'termination_z'
'provider', 'type', 'tenant', 'tenant__group', 'termination_a', 'termination_z'
)
filterset = filtersets.CircuitFilterSet
filterset_form = forms.CircuitFilterForm
Expand Down
7 changes: 3 additions & 4 deletions netbox/dcim/tables/cables.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from dcim.models import Cable
from netbox.tables import NetBoxTable, columns
from tenancy.tables import TenantColumn
from tenancy.tables import TenancyColumnsMixin
from .template_code import CABLE_LENGTH, CABLE_TERMINATION_PARENT

__all__ = (
Expand All @@ -15,7 +15,7 @@
# Cables
#

class CableTable(NetBoxTable):
class CableTable(TenancyColumnsMixin, NetBoxTable):
termination_a_parent = tables.TemplateColumn(
template_code=CABLE_TERMINATION_PARENT,
accessor=Accessor('termination_a'),
Expand Down Expand Up @@ -53,7 +53,6 @@ class CableTable(NetBoxTable):
verbose_name='Termination B'
)
status = columns.ChoiceFieldColumn()
tenant = TenantColumn()
length = columns.TemplateColumn(
template_code=CABLE_LENGTH,
order_by=('_abs_length', 'length_unit')
Expand All @@ -67,7 +66,7 @@ class Meta(NetBoxTable.Meta):
model = Cable
fields = (
'pk', 'id', 'label', 'termination_a_parent', 'rack_a', 'termination_a', 'termination_b_parent', 'rack_b', 'termination_b',
'status', 'type', 'tenant', 'color', 'length', 'tags', 'created', 'last_updated',
'status', 'type', 'tenant', 'tenant_group', 'color', 'length', 'tags', 'created', 'last_updated',
)
default_columns = (
'pk', 'id', 'label', 'termination_a_parent', 'termination_a', 'termination_b_parent', 'termination_b',
Expand Down
12 changes: 5 additions & 7 deletions netbox/dcim/tables/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
InventoryItemRole, ModuleBay, Platform, PowerOutlet, PowerPort, RearPort, VirtualChassis,
)
from netbox.tables import NetBoxTable, columns
from tenancy.tables import TenantColumn
from tenancy.tables import TenancyColumnsMixin
from .template_code import *

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

class DeviceTable(NetBoxTable):
class DeviceTable(TenancyColumnsMixin, NetBoxTable):
name = tables.TemplateColumn(
order_by=('_name',),
template_code=DEVICE_LINK
)
status = columns.ChoiceFieldColumn()
tenant = TenantColumn()
site = tables.Column(
linkify=True
)
Expand Down Expand Up @@ -200,7 +199,7 @@ class DeviceTable(NetBoxTable):
class Meta(NetBoxTable.Meta):
model = Device
fields = (
'pk', 'id', 'name', 'status', 'tenant', 'device_role', 'manufacturer', 'device_type', 'platform', 'serial',
'pk', 'id', 'name', 'status', 'tenant', 'tenant_group', 'device_role', 'manufacturer', 'device_type', 'platform', 'serial',
'asset_tag', 'site', 'location', 'rack', 'position', 'face', 'primary_ip', 'airflow', 'primary_ip4',
'primary_ip6', 'cluster', 'virtual_chassis', 'vc_position', 'vc_priority', 'comments', 'contacts', 'tags',
'created', 'last_updated',
Expand All @@ -211,12 +210,11 @@ class Meta(NetBoxTable.Meta):
)


class DeviceImportTable(NetBoxTable):
class DeviceImportTable(TenancyColumnsMixin, NetBoxTable):
name = tables.TemplateColumn(
template_code=DEVICE_LINK
)
status = columns.ChoiceFieldColumn()
tenant = TenantColumn()
site = tables.Column(
linkify=True
)
Expand All @@ -232,7 +230,7 @@ class DeviceImportTable(NetBoxTable):

class Meta(NetBoxTable.Meta):
model = Device
fields = ('id', 'name', 'status', 'tenant', 'site', 'rack', 'position', 'device_role', 'device_type')
fields = ('id', 'name', 'status', 'tenant', 'tenant_group', 'site', 'rack', 'position', 'device_role', 'device_type')
empty_text = False


Expand Down
12 changes: 5 additions & 7 deletions netbox/dcim/tables/racks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

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

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

class RackTable(NetBoxTable):
class RackTable(TenancyColumnsMixin, NetBoxTable):
name = tables.Column(
order_by=('_name',),
linkify=True
Expand All @@ -48,7 +48,6 @@ class RackTable(NetBoxTable):
site = tables.Column(
linkify=True
)
tenant = TenantColumn()
status = columns.ChoiceFieldColumn()
role = columns.ColoredLabelColumn()
u_height = tables.TemplateColumn(
Expand Down Expand Up @@ -87,7 +86,7 @@ class RackTable(NetBoxTable):
class Meta(NetBoxTable.Meta):
model = Rack
fields = (
'pk', 'id', 'name', 'site', 'location', 'status', 'facility_id', 'tenant', 'role', 'serial', 'asset_tag',
'pk', 'id', 'name', 'site', 'location', 'status', 'facility_id', 'tenant', 'tenant_group', 'role', 'serial', 'asset_tag',
'type', 'width', 'outer_width', 'outer_depth', 'u_height', 'comments', 'device_count', 'get_utilization',
'get_power_utilization', 'contacts', 'tags', 'created', 'last_updated',
)
Expand All @@ -101,7 +100,7 @@ class Meta(NetBoxTable.Meta):
# Rack reservations
#

class RackReservationTable(NetBoxTable):
class RackReservationTable(TenancyColumnsMixin, NetBoxTable):
reservation = tables.Column(
accessor='pk',
linkify=True
Expand All @@ -110,7 +109,6 @@ class RackReservationTable(NetBoxTable):
accessor=Accessor('rack__site'),
linkify=True
)
tenant = TenantColumn()
rack = tables.Column(
linkify=True
)
Expand All @@ -125,7 +123,7 @@ class RackReservationTable(NetBoxTable):
class Meta(NetBoxTable.Meta):
model = RackReservation
fields = (
'pk', 'id', 'reservation', 'site', 'rack', 'unit_list', 'user', 'created', 'tenant', 'description', 'tags',
'pk', 'id', 'reservation', 'site', 'rack', 'unit_list', 'user', 'created', 'tenant', 'tenant_group', 'description', 'tags',
'actions', 'created', 'last_updated',
)
default_columns = ('pk', 'reservation', 'site', 'rack', 'unit_list', 'user', 'description')
12 changes: 5 additions & 7 deletions netbox/dcim/tables/sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from dcim.models import Location, Region, Site, SiteGroup
from netbox.tables import NetBoxTable, columns
from tenancy.tables import TenantColumn
from tenancy.tables import TenancyColumnsMixin
from .template_code import LOCATION_BUTTONS

__all__ = (
Expand Down Expand Up @@ -75,7 +75,7 @@ class Meta(NetBoxTable.Meta):
# Sites
#

class SiteTable(NetBoxTable):
class SiteTable(TenancyColumnsMixin, NetBoxTable):
name = tables.Column(
linkify=True
)
Expand All @@ -96,7 +96,6 @@ class SiteTable(NetBoxTable):
url_params={'site_id': 'pk'},
verbose_name='ASN Count'
)
tenant = TenantColumn()
comments = columns.MarkdownColumn()
contacts = columns.ManyToManyColumn(
linkify_item=True
Expand All @@ -108,7 +107,7 @@ class SiteTable(NetBoxTable):
class Meta(NetBoxTable.Meta):
model = Site
fields = (
'pk', 'id', 'name', 'slug', 'status', 'facility', 'region', 'group', 'tenant', 'asns', 'asn_count',
'pk', 'id', 'name', 'slug', 'status', 'facility', 'region', 'group', 'tenant', 'tenant_group', 'asns', 'asn_count',
'time_zone', 'description', 'physical_address', 'shipping_address', 'latitude', 'longitude', 'comments',
'contacts', 'tags', 'created', 'last_updated', 'actions',
)
Expand All @@ -119,14 +118,13 @@ class Meta(NetBoxTable.Meta):
# Locations
#

class LocationTable(NetBoxTable):
class LocationTable(TenancyColumnsMixin, NetBoxTable):
name = columns.MPTTColumn(
linkify=True
)
site = tables.Column(
linkify=True
)
tenant = TenantColumn()
rack_count = columns.LinkedCountColumn(
viewname='dcim:rack_list',
url_params={'location_id': 'pk'},
Expand All @@ -150,7 +148,7 @@ class LocationTable(NetBoxTable):
class Meta(NetBoxTable.Meta):
model = Location
fields = (
'pk', 'id', 'name', 'site', 'tenant', 'rack_count', 'device_count', 'description', 'slug', 'contacts',
'pk', 'id', 'name', 'site', 'tenant', 'tenant_group', 'rack_count', 'device_count', 'description', 'slug', 'contacts',
'tags', 'actions', 'created', 'last_updated',
)
default_columns = ('pk', 'name', 'site', 'tenant', 'rack_count', 'device_count', 'description')
2 changes: 1 addition & 1 deletion netbox/dcim/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ class RackRoleBulkDeleteView(generic.BulkDeleteView):

class RackListView(generic.ObjectListView):
queryset = Rack.objects.prefetch_related(
'site', 'location', 'tenant', 'role', 'devices__device_type'
'site', 'location', 'tenant', 'tenant_group', 'role', 'devices__device_type'
).annotate(
device_count=count_related(Device, 'rack')
)
Expand Down
Loading