mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Merge v3.1.7
This commit is contained in:
31
netbox/dcim/migrations/0144_fix_cable_abs_length.py
Normal file
31
netbox/dcim/migrations/0144_fix_cable_abs_length.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from django.db import migrations
|
||||
|
||||
from utilities.utils import to_meters
|
||||
|
||||
|
||||
def recalculate_abs_length(apps, schema_editor):
|
||||
"""
|
||||
Recalculate absolute lengths for all cables with a length and length unit defined. Fixes
|
||||
incorrectly calculated values as reported under bug #8377.
|
||||
"""
|
||||
Cable = apps.get_model('dcim', 'Cable')
|
||||
|
||||
cables = Cable.objects.filter(length__isnull=False).exclude(length_unit='')
|
||||
for cable in cables:
|
||||
cable._abs_length = to_meters(cable.length, cable.length_unit)
|
||||
|
||||
Cable.objects.bulk_update(cables, ['_abs_length'], batch_size=100)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('dcim', '0143_remove_primary_for_related_name'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(
|
||||
code=recalculate_abs_length,
|
||||
reverse_code=migrations.RunPython.noop
|
||||
),
|
||||
]
|
@@ -4,7 +4,7 @@ from django.db import migrations
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('dcim', '0143_remove_primary_for_related_name'),
|
||||
('dcim', '0144_fix_cable_abs_length'),
|
||||
]
|
||||
|
||||
operations = [
|
@@ -10,7 +10,7 @@ class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('extras', '0066_customfield_name_validation'),
|
||||
('dcim', '0144_site_remove_deprecated_fields'),
|
||||
('dcim', '0145_site_remove_deprecated_fields'),
|
||||
]
|
||||
|
||||
operations = [
|
@@ -9,7 +9,7 @@ class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('extras', '0068_configcontext_cluster_types'),
|
||||
('dcim', '0145_modules'),
|
||||
('dcim', '0146_modules'),
|
||||
]
|
||||
|
||||
operations = [
|
@@ -6,7 +6,7 @@ class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('contenttypes', '0002_remove_content_type_name'),
|
||||
('dcim', '0146_inventoryitemrole'),
|
||||
('dcim', '0147_inventoryitemrole'),
|
||||
]
|
||||
|
||||
operations = [
|
@@ -9,7 +9,7 @@ class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('contenttypes', '0002_remove_content_type_name'),
|
||||
('dcim', '0147_inventoryitem_component'),
|
||||
('dcim', '0148_inventoryitem_component'),
|
||||
]
|
||||
|
||||
operations = [
|
@@ -8,7 +8,7 @@ class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('ipam', '0054_vlangroup_min_max_vids'),
|
||||
('dcim', '0148_inventoryitem_templates'),
|
||||
('dcim', '0149_inventoryitem_templates'),
|
||||
]
|
||||
|
||||
operations = [
|
@@ -6,7 +6,7 @@ from django.db import migrations, models
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('dcim', '0149_interface_vrf'),
|
||||
('dcim', '0150_interface_vrf'),
|
||||
]
|
||||
|
||||
operations = [
|
@@ -4,7 +4,7 @@ from django.db import migrations, models
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('dcim', '0150_interface_speed_duplex'),
|
||||
('dcim', '0151_interface_speed_duplex'),
|
||||
]
|
||||
|
||||
operations = [
|
Reference in New Issue
Block a user