mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Implement get_subquery() for annotation of child object counts; Rename dcim.Site 'count_*' fields
This commit is contained in:
@@ -363,32 +363,6 @@ class Site(ChangeLoggedModel, CustomFieldModel):
|
||||
def get_status_class(self):
|
||||
return STATUS_CLASSES[self.status]
|
||||
|
||||
@property
|
||||
def count_prefixes(self):
|
||||
return self.prefixes.count()
|
||||
|
||||
@property
|
||||
def count_vlans(self):
|
||||
return self.vlans.count()
|
||||
|
||||
@property
|
||||
def count_racks(self):
|
||||
return Rack.objects.filter(site=self).count()
|
||||
|
||||
@property
|
||||
def count_devices(self):
|
||||
return Device.objects.filter(site=self).count()
|
||||
|
||||
@property
|
||||
def count_circuits(self):
|
||||
from circuits.models import Circuit
|
||||
return Circuit.objects.filter(terminations__site=self).count()
|
||||
|
||||
@property
|
||||
def count_vms(self):
|
||||
from virtualization.models import VirtualMachine
|
||||
return VirtualMachine.objects.filter(cluster__site=self).count()
|
||||
|
||||
|
||||
#
|
||||
# Racks
|
||||
|
Reference in New Issue
Block a user