mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-14 01:41:22 -06:00
Fixes #2639: Fix preservation of length/dimensions unit for racks and cables
This commit is contained in:
parent
d1cd366dc9
commit
a3ade01224
@ -45,6 +45,7 @@ NetBox now supports modeling physical cables for console, power, and interface c
|
|||||||
* [#2622](https://github.com/digitalocean/netbox/issues/2622) - Enable filtering cables by multiple types/colors
|
* [#2622](https://github.com/digitalocean/netbox/issues/2622) - Enable filtering cables by multiple types/colors
|
||||||
* [#2624](https://github.com/digitalocean/netbox/issues/2624) - Delete associated content type and permissions when removing InterfaceConnection model
|
* [#2624](https://github.com/digitalocean/netbox/issues/2624) - Delete associated content type and permissions when removing InterfaceConnection model
|
||||||
* [#2616](https://github.com/digitalocean/netbox/issues/2616) - Convert Rack `outer_unit` and Cable `length_unit` to integer-based choice fields
|
* [#2616](https://github.com/digitalocean/netbox/issues/2616) - Convert Rack `outer_unit` and Cable `length_unit` to integer-based choice fields
|
||||||
|
* [#2639](https://github.com/digitalocean/netbox/issues/2639) - Fix preservation of length/dimensions unit for racks and cables
|
||||||
|
|
||||||
## API Changes
|
## API Changes
|
||||||
|
|
||||||
|
@ -554,7 +554,7 @@ class Rack(ChangeLoggedModel, CustomFieldModel):
|
|||||||
# Validate outer dimensions and unit
|
# Validate outer dimensions and unit
|
||||||
if (self.outer_width is not None or self.outer_depth is not None) and self.outer_unit is None:
|
if (self.outer_width is not None or self.outer_depth is not None) and self.outer_unit is None:
|
||||||
raise ValidationError("Must specify a unit when setting an outer width/depth")
|
raise ValidationError("Must specify a unit when setting an outer width/depth")
|
||||||
else:
|
elif self.outer_width is None and self.outer_depth is None:
|
||||||
self.outer_unit = None
|
self.outer_unit = None
|
||||||
|
|
||||||
if self.pk:
|
if self.pk:
|
||||||
@ -2586,7 +2586,7 @@ class Cable(ChangeLoggedModel):
|
|||||||
# Validate length and length_unit
|
# Validate length and length_unit
|
||||||
if self.length is not None and self.length_unit is None:
|
if self.length is not None and self.length_unit is None:
|
||||||
raise ValidationError("Must specify a unit when setting a cable length")
|
raise ValidationError("Must specify a unit when setting a cable length")
|
||||||
else:
|
elif self.length is None:
|
||||||
self.length_unit = None
|
self.length_unit = None
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
</h4>
|
</h4>
|
||||||
{{ cable.get_status_display }}<br />
|
{{ cable.get_status_display }}<br />
|
||||||
{{ cable.get_type_display|default:"" }}
|
{{ cable.get_type_display|default:"" }}
|
||||||
{% if cable.length %}- {{ cable.length }}{{ cable.length_unit }}{% endif %}
|
{% if cable.length %}- {{ cable.length }}{{ cable.get_length_unit_display }}{% endif %}
|
||||||
<span class="label color-block center-block" style="background-color: #{{ cable.color }}"> </span>
|
<span class="label color-block center-block" style="background-color: #{{ cable.color }}"> </span>
|
||||||
{% else %}
|
{% else %}
|
||||||
<h4 class="text-muted">No Cable</h4>
|
<h4 class="text-muted">No Cable</h4>
|
||||||
|
@ -158,7 +158,7 @@
|
|||||||
<td>Outer Width</td>
|
<td>Outer Width</td>
|
||||||
<td>
|
<td>
|
||||||
{% if rack.outer_width %}
|
{% if rack.outer_width %}
|
||||||
<span>{{ rack.outer_width }}{{ rack.outer_unit }}</span>
|
<span>{{ rack.outer_width }} {{ rack.get_outer_unit_display }}</span>
|
||||||
{% else %}
|
{% else %}
|
||||||
<span class="text-muted">—</span>
|
<span class="text-muted">—</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -168,7 +168,7 @@
|
|||||||
<td>Outer Depth</td>
|
<td>Outer Depth</td>
|
||||||
<td>
|
<td>
|
||||||
{% if rack.outer_depth %}
|
{% if rack.outer_depth %}
|
||||||
<span>{{ rack.outer_depth }}{{ rack.outer_unit }}</span>
|
<span>{{ rack.outer_depth }} {{ rack.get_outer_unit_display }}</span>
|
||||||
{% else %}
|
{% else %}
|
||||||
<span class="text-muted">—</span>
|
<span class="text-muted">—</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
Loading…
Reference in New Issue
Block a user