mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-24 00:15:17 -06:00
9654 add weight fields to devices
This commit is contained in:
parent
a869720cca
commit
844a2085b4
@ -452,7 +452,7 @@ class Rack(NetBoxModel, DeviceWeightMixin):
|
||||
|
||||
def get_total_weight(self):
|
||||
total_weight = sum(device.device_type._abs_weight for device in self.devices.exclude(device_type___abs_weight__isnull=True).prefetch_related('device_type'))
|
||||
total_weight += sum(module.module_type._abs_weight for module in Module.objects.filter(device=self).exclude(module_type___abs_weight__isnull=True).prefetch_related('module_type'))
|
||||
total_weight += sum(module.module_type._abs_weight for module in Module.objects.filter(device__rack=self).exclude(module_type___abs_weight__isnull=True).prefetch_related('module_type'))
|
||||
total_weight += self._abs_weight
|
||||
return total_weight
|
||||
|
||||
|
@ -186,6 +186,27 @@
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if object.get_total_weight %}
|
||||
<div class="card">
|
||||
<h5 class="card-header">
|
||||
Weight
|
||||
</h5>
|
||||
<div class="card-body">
|
||||
<table class="table table-hover attr-table">
|
||||
<tr>
|
||||
<th scope="row">Rack Weight</th>
|
||||
<td>{{ object.weight }} kg</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Total Weight</th>
|
||||
<td>{{ object.get_total_weight }} kg</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% include 'inc/panels/image_attachments.html' %}
|
||||
<div class="card">
|
||||
<h5 class="card-header">
|
||||
|
Loading…
Reference in New Issue
Block a user