Fixes #3125: Fix exception when viewing PDUs

This commit is contained in:
Jeremy Stretch 2019-04-30 12:24:53 -04:00
parent 73927d2d56
commit 088903218d
4 changed files with 7 additions and 6 deletions

View File

@ -3,6 +3,7 @@ v2.6.0 (FUTURE)
## Bug Fixes (From Beta)
* [#3123](https://github.com/digitalocean/netbox/issues/3123) - Exempt `/metrics` view from authentication
* [#3125](https://github.com/digitalocean/netbox/issues/3125) - Fix exception when viewing PDUs
---

View File

@ -1956,8 +1956,8 @@ class PowerPort(CableTermination, ComponentModel):
outlet_ids = PowerOutlet.objects.filter(power_port=self).values_list('pk', flat=True)
utilization = PowerPort.objects.filter(_connected_poweroutlet_id__in=outlet_ids).aggregate(
maximum_draw=Sum('maximum_draw'),
allocated_draw=Sum('allocated_draw'),
maximum_draw_total=Sum('maximum_draw'),
allocated_draw_total=Sum('allocated_draw'),
)
utilization['outlets'] = len(outlet_ids)
utilization['available_power'] = powerfeed_available
@ -1968,8 +1968,8 @@ class PowerPort(CableTermination, ComponentModel):
for leg, leg_name in POWERFEED_LEG_CHOICES:
outlet_ids = PowerOutlet.objects.filter(power_port=self, feed_leg=leg).values_list('pk', flat=True)
utilization = PowerPort.objects.filter(_connected_poweroutlet_id__in=outlet_ids).aggregate(
maximum_draw=Sum('maximum_draw'),
allocated_draw=Sum('allocated_draw'),
maximum_draw_total=Sum('maximum_draw'),
allocated_draw_total=Sum('allocated_draw'),
)
utilization['name'] = 'Leg {}'.format(leg_name)
utilization['outlets'] = len(outlet_ids)

View File

@ -934,7 +934,7 @@ class DeviceView(PermissionRequiredMixin, View):
power_ports = device.powerports.select_related('_connected_poweroutlet__device', 'cable')
# Power outlets
poweroutlets = device.poweroutlets.select_related('connected_endpoint__device', 'cable')
poweroutlets = device.poweroutlets.select_related('connected_endpoint__device', 'cable', 'power_port')
# Interfaces
interfaces = device.vc_interfaces.select_related(

View File

@ -361,7 +361,7 @@
<td>{{ pp }}</td>
{% endif %}
<td>{{ leg.outlets|placeholder }}</td>
<td>{{ leg.allocated_draw }} / {{ leg.maximum_draw }}</td>
<td>{{ leg.allocated_draw_total }} / {{ leg.maximum_draw_total }}</td>
<td>{{ leg.available_power }}</td>
</tr>
{% endfor %}