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

Closes #6154: Allow decimal values for cable lengths

This commit is contained in:
jeremystretch
2021-05-10 14:14:54 -04:00
parent a6d937b366
commit f3abf84e17
5 changed files with 24 additions and 3 deletions

View File

@ -5,6 +5,7 @@
### Enhancements
* [#5806](https://github.com/netbox-community/netbox/issues/5806) - Add kilometer and mile as choices for cable length unit
* [#6154](https://github.com/netbox-community/netbox/issues/6154) - Allow decimal values for cable lengths
### Other Changes
@ -13,6 +14,8 @@
### REST API Changes
* dcim.Cable
* `length` is now a decimal value
* dcim.Device
* Removed the `display_name` attribute (use `display` instead)
* dcim.DeviceType

View File

@ -0,0 +1,16 @@
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('dcim', '0131_consoleport_speed'),
]
operations = [
migrations.AlterField(
model_name='cable',
name='length',
field=models.DecimalField(blank=True, decimal_places=2, max_digits=8, null=True),
),
]

View File

@ -74,7 +74,9 @@ class Cable(PrimaryModel):
color = ColorField(
blank=True
)
length = models.PositiveSmallIntegerField(
length = models.DecimalField(
max_digits=8,
decimal_places=2,
blank=True,
null=True
)

View File

@ -60,7 +60,7 @@
<th scope="row">Length</th>
<td>
{% if object.length %}
{{ object.length }} {{ object.get_length_unit_display }}
{{ object.length|floatformat }} {{ object.get_length_unit_display }}
{% else %}
<span class="text-muted">&mdash;</span>
{% endif %}

View File

@ -10,7 +10,7 @@
<span class="badge bg-secondary">{{ cable.get_type_display|default:"" }}</span>
{% endif %}
{% if cable.length %}
({{ cable.length }} {{ cable.get_length_unit_display }})<br />
({{ cable.length|floatformat }} {{ cable.get_length_unit_display }})<br />
{% endif %}
<span class="badge bg-{{ cable.get_status_class }}">{{ cable.get_status_display }}</span><br />
{% for tag in cable.tags.all %}