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

Rack.outer_unit to slug (#3569)

This commit is contained in:
Jeremy Stretch
2019-11-25 20:54:24 -05:00
parent 4846557d61
commit 9872a46583
7 changed files with 62 additions and 24 deletions

View File

@@ -16,6 +16,11 @@ RACK_STATUS_CHOICES = (
(4, 'deprecated'),
)
RACK_DIMENSION_CHOICES = (
(1000, 'mm'),
(2000, 'in'),
)
def rack_type_to_slug(apps, schema_editor):
Rack = apps.get_model('dcim', 'Rack')
@@ -29,6 +34,12 @@ def rack_status_to_slug(apps, schema_editor):
Rack.objects.filter(status=str(id)).update(status=slug)
def rack_outer_unit_to_slug(apps, schema_editor):
Rack = apps.get_model('dcim', 'Rack')
for id, slug in RACK_DIMENSION_CHOICES:
Rack.objects.filter(status=str(id)).update(status=slug)
class Migration(migrations.Migration):
atomic = False
@@ -62,4 +73,19 @@ class Migration(migrations.Migration):
migrations.RunPython(
code=rack_status_to_slug
),
# Rack.outer_unit
migrations.AlterField(
model_name='rack',
name='outer_unit',
field=models.CharField(blank=True, default='', max_length=50),
),
migrations.RunPython(
code=rack_outer_unit_to_slug
),
migrations.AlterField(
model_name='rack',
name='outer_unit',
field=models.CharField(blank=True, max_length=50),
),
]