mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Cable.status to slug (#3569)
This commit is contained in:
@@ -23,6 +23,11 @@ CABLE_TYPE_CHOICES = (
|
||||
(5000, 'power'),
|
||||
)
|
||||
|
||||
CABLE_STATUS_CHOICES = (
|
||||
(True, 'connected'),
|
||||
(False, 'planned'),
|
||||
)
|
||||
|
||||
CABLE_LENGTH_UNIT_CHOICES = (
|
||||
(1200, 'm'),
|
||||
(1100, 'cm'),
|
||||
@@ -37,6 +42,12 @@ def cable_type_to_slug(apps, schema_editor):
|
||||
Cable.objects.filter(type=id).update(type=slug)
|
||||
|
||||
|
||||
def cable_status_to_slug(apps, schema_editor):
|
||||
Cable = apps.get_model('dcim', 'Cable')
|
||||
for bool, slug in CABLE_STATUS_CHOICES:
|
||||
Cable.objects.filter(status=str(bool)).update(status=slug)
|
||||
|
||||
|
||||
def cable_length_unit_to_slug(apps, schema_editor):
|
||||
Cable = apps.get_model('dcim', 'Cable')
|
||||
for id, slug in CABLE_LENGTH_UNIT_CHOICES:
|
||||
@@ -67,6 +78,16 @@ class Migration(migrations.Migration):
|
||||
field=models.CharField(blank=True, max_length=50),
|
||||
),
|
||||
|
||||
# Cable.status
|
||||
migrations.AlterField(
|
||||
model_name='cable',
|
||||
name='status',
|
||||
field=models.CharField(max_length=50),
|
||||
),
|
||||
migrations.RunPython(
|
||||
code=cable_status_to_slug
|
||||
),
|
||||
|
||||
# Cable.length_unit
|
||||
migrations.AlterField(
|
||||
model_name='cable',
|
||||
|
Reference in New Issue
Block a user