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

Rack.status to slug (#3569)

This commit is contained in:
Jeremy Stretch
2019-11-15 22:03:41 -05:00
parent e1e09bff9b
commit c79c29e769
7 changed files with 69 additions and 25 deletions

View File

@@ -8,6 +8,14 @@ RACK_TYPE_CHOICES = (
(1100, 'wall-cabinet'),
)
RACK_STATUS_CHOICES = (
(0, 'reserved'),
(1, 'available'),
(2, 'planned'),
(3, 'active'),
(4, 'deprecated'),
)
def rack_type_to_slug(apps, schema_editor):
Rack = apps.get_model('dcim', 'Rack')
@@ -15,6 +23,12 @@ def rack_type_to_slug(apps, schema_editor):
Rack.objects.filter(type=str(id)).update(type=slug)
def rack_status_to_slug(apps, schema_editor):
Rack = apps.get_model('dcim', 'Rack')
for id, slug in RACK_STATUS_CHOICES:
Rack.objects.filter(status=str(id)).update(status=slug)
class Migration(migrations.Migration):
dependencies = [
@@ -22,6 +36,7 @@ class Migration(migrations.Migration):
]
operations = [
# Rack.type
migrations.AlterField(
model_name='rack',
name='type',
@@ -29,5 +44,14 @@ class Migration(migrations.Migration):
),
migrations.RunPython(
code=rack_type_to_slug
)
),
# Rack.status
migrations.AlterField(
model_name='rack',
name='status',
field=models.CharField(blank=True, max_length=50),
),
migrations.RunPython(
code=rack_status_to_slug
),
]