1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Fixes #660: Correct calculation of utilized space for rack list display

This commit is contained in:
Jeremy Stretch
2016-10-31 16:44:00 -04:00
parent 2d58cfaa05
commit 41af9c8900
3 changed files with 8 additions and 13 deletions

View File

@@ -7,8 +7,7 @@ from django.contrib.auth.decorators import permission_required
from django.contrib.auth.mixins import PermissionRequiredMixin
from django.core.exceptions import ValidationError
from django.core.urlresolvers import reverse
from django.db.models import Count, Sum
from django.db.models.functions import Coalesce
from django.db.models import Count
from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404, redirect, render
from django.utils.http import urlencode
@@ -181,8 +180,7 @@ class RackRoleBulkDeleteView(PermissionRequiredMixin, BulkDeleteView):
class RackListView(ObjectListView):
queryset = Rack.objects.select_related('site', 'group', 'tenant', 'role').prefetch_related('devices__device_type')\
.annotate(device_count=Count('devices', distinct=True),
u_consumed=Coalesce(Sum('devices__device_type__u_height'), 0))
.annotate(device_count=Count('devices', distinct=True))
filter = filters.RackFilter
filter_form = forms.RackFilterForm
table = tables.RackTable