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

Interface.mode to slug (#3569)

This commit is contained in:
Jeremy Stretch
2019-11-21 22:39:15 -05:00
parent f93cd17fee
commit 3fa4ceadb0
10 changed files with 76 additions and 46 deletions

View File

@@ -75,6 +75,13 @@ INTERFACE_TYPE_CHOICES = (
)
INTERFACE_MODE_CHOICES = (
(100, 'access'),
(200, 'tagged'),
(300, 'tagged-all'),
)
def interfacetemplate_type_to_slug(apps, schema_editor):
InterfaceTemplate = apps.get_model('dcim', 'InterfaceTemplate')
for id, slug in INTERFACE_TYPE_CHOICES:
@@ -87,6 +94,12 @@ def interface_type_to_slug(apps, schema_editor):
Interface.objects.filter(type=id).update(type=slug)
def interface_mode_to_slug(apps, schema_editor):
Interface = apps.get_model('dcim', 'Interface')
for id, slug in INTERFACE_MODE_CHOICES:
Interface.objects.filter(mode=id).update(mode=slug)
class Migration(migrations.Migration):
atomic = False
@@ -111,4 +124,17 @@ class Migration(migrations.Migration):
migrations.RunPython(
code=interface_type_to_slug
),
migrations.AlterField(
model_name='interface',
name='mode',
field=models.CharField(blank=True, default='', max_length=50),
),
migrations.RunPython(
code=interface_mode_to_slug
),
migrations.AlterField(
model_name='interface',
name='mode',
field=models.CharField(blank=True, max_length=50),
),
]