mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-20 02:06:42 -06:00
Closes #6109: Add device counts to locations table
This commit is contained in:
parent
4f7626828a
commit
05d8a06cd5
@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
## v2.11.0 (FUTURE)
|
## v2.11.0 (FUTURE)
|
||||||
|
|
||||||
|
### Enhancements (from Beta)
|
||||||
|
|
||||||
|
* [#6109](https://github.com/netbox-community/netbox/issues/6109) - Add device counts to locations table
|
||||||
|
|
||||||
### Bug Fixes (from Beta)
|
### Bug Fixes (from Beta)
|
||||||
|
|
||||||
* [#6100](https://github.com/netbox-community/netbox/issues/6100) - Fix VM interfaces table "add interfaces" link
|
* [#6100](https://github.com/netbox-community/netbox/issues/6100) - Fix VM interfaces table "add interfaces" link
|
||||||
|
@ -1,49 +1,21 @@
|
|||||||
import django_tables2 as tables
|
import django_tables2 as tables
|
||||||
from django_tables2.utils import Accessor
|
from django_tables2.utils import Accessor
|
||||||
|
|
||||||
from dcim.models import Rack, Location, RackReservation, RackRole
|
from dcim.models import Rack, RackReservation, RackRole
|
||||||
from tenancy.tables import TenantColumn
|
from tenancy.tables import TenantColumn
|
||||||
from utilities.tables import (
|
from utilities.tables import (
|
||||||
BaseTable, ButtonsColumn, ChoiceFieldColumn, ColorColumn, ColoredLabelColumn, LinkedCountColumn, MPTTColumn,
|
BaseTable, ButtonsColumn, ChoiceFieldColumn, ColorColumn, ColoredLabelColumn, LinkedCountColumn, TagColumn,
|
||||||
TagColumn, ToggleColumn, UtilizationColumn,
|
ToggleColumn, UtilizationColumn,
|
||||||
)
|
)
|
||||||
from .template_code import LOCATION_ELEVATIONS
|
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
'RackTable',
|
'RackTable',
|
||||||
'RackDetailTable',
|
'RackDetailTable',
|
||||||
'LocationTable',
|
|
||||||
'RackReservationTable',
|
'RackReservationTable',
|
||||||
'RackRoleTable',
|
'RackRoleTable',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Locations
|
|
||||||
#
|
|
||||||
|
|
||||||
class LocationTable(BaseTable):
|
|
||||||
pk = ToggleColumn()
|
|
||||||
name = MPTTColumn(
|
|
||||||
linkify=True
|
|
||||||
)
|
|
||||||
site = tables.Column(
|
|
||||||
linkify=True
|
|
||||||
)
|
|
||||||
rack_count = tables.Column(
|
|
||||||
verbose_name='Racks'
|
|
||||||
)
|
|
||||||
actions = ButtonsColumn(
|
|
||||||
model=Location,
|
|
||||||
prepend_template=LOCATION_ELEVATIONS
|
|
||||||
)
|
|
||||||
|
|
||||||
class Meta(BaseTable.Meta):
|
|
||||||
model = Location
|
|
||||||
fields = ('pk', 'name', 'site', 'rack_count', 'description', 'slug', 'actions')
|
|
||||||
default_columns = ('pk', 'name', 'site', 'rack_count', 'description', 'actions')
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Rack roles
|
# Rack roles
|
||||||
#
|
#
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
import django_tables2 as tables
|
import django_tables2 as tables
|
||||||
|
|
||||||
from dcim.models import Region, Site, SiteGroup
|
from dcim.models import Location, Region, Site, SiteGroup
|
||||||
from tenancy.tables import TenantColumn
|
from tenancy.tables import TenantColumn
|
||||||
from utilities.tables import (
|
from utilities.tables import (
|
||||||
BaseTable, ButtonsColumn, ChoiceFieldColumn, LinkedCountColumn, MPTTColumn, TagColumn, ToggleColumn,
|
BaseTable, ButtonsColumn, ChoiceFieldColumn, LinkedCountColumn, MPTTColumn, TagColumn, ToggleColumn,
|
||||||
)
|
)
|
||||||
|
from .template_code import LOCATION_ELEVATIONS
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
|
'LocationTable',
|
||||||
'RegionTable',
|
'RegionTable',
|
||||||
'SiteTable',
|
'SiteTable',
|
||||||
'SiteGroupTable',
|
'SiteGroupTable',
|
||||||
@ -86,3 +88,32 @@ class SiteTable(BaseTable):
|
|||||||
'contact_email', 'tags',
|
'contact_email', 'tags',
|
||||||
)
|
)
|
||||||
default_columns = ('pk', 'name', 'status', 'facility', 'region', 'group', 'tenant', 'asn', 'description')
|
default_columns = ('pk', 'name', 'status', 'facility', 'region', 'group', 'tenant', 'asn', 'description')
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Locations
|
||||||
|
#
|
||||||
|
|
||||||
|
class LocationTable(BaseTable):
|
||||||
|
pk = ToggleColumn()
|
||||||
|
name = MPTTColumn(
|
||||||
|
linkify=True
|
||||||
|
)
|
||||||
|
site = tables.Column(
|
||||||
|
linkify=True
|
||||||
|
)
|
||||||
|
rack_count = tables.Column(
|
||||||
|
verbose_name='Racks'
|
||||||
|
)
|
||||||
|
device_count = tables.Column(
|
||||||
|
verbose_name='Devices'
|
||||||
|
)
|
||||||
|
actions = ButtonsColumn(
|
||||||
|
model=Location,
|
||||||
|
prepend_template=LOCATION_ELEVATIONS
|
||||||
|
)
|
||||||
|
|
||||||
|
class Meta(BaseTable.Meta):
|
||||||
|
model = Location
|
||||||
|
fields = ('pk', 'name', 'site', 'rack_count', 'device_count', 'description', 'slug', 'actions')
|
||||||
|
default_columns = ('pk', 'name', 'site', 'rack_count', 'device_count', 'description', 'actions')
|
||||||
|
@ -338,12 +338,18 @@ class SiteBulkDeleteView(generic.BulkDeleteView):
|
|||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Rack groups
|
# Locations
|
||||||
#
|
#
|
||||||
|
|
||||||
class LocationListView(generic.ObjectListView):
|
class LocationListView(generic.ObjectListView):
|
||||||
queryset = Location.objects.add_related_count(
|
queryset = Location.objects.add_related_count(
|
||||||
|
Location.objects.add_related_count(
|
||||||
Location.objects.all(),
|
Location.objects.all(),
|
||||||
|
Device,
|
||||||
|
'location',
|
||||||
|
'device_count',
|
||||||
|
cumulative=True
|
||||||
|
),
|
||||||
Rack,
|
Rack,
|
||||||
'location',
|
'location',
|
||||||
'rack_count',
|
'rack_count',
|
||||||
|
Loading…
Reference in New Issue
Block a user