mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
VLAN.status to slug (#3569)
This commit is contained in:
36
netbox/ipam/migrations/0030_3569_vlan_fields.py
Normal file
36
netbox/ipam/migrations/0030_3569_vlan_fields.py
Normal file
@@ -0,0 +1,36 @@
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
VLAN_STATUS_CHOICES = (
|
||||
(1, 'active'),
|
||||
(2, 'reserved'),
|
||||
(3, 'deprecated'),
|
||||
)
|
||||
|
||||
|
||||
def vlan_status_to_slug(apps, schema_editor):
|
||||
VLAN = apps.get_model('ipam', 'VLAN')
|
||||
for id, slug in VLAN_STATUS_CHOICES:
|
||||
VLAN.objects.filter(status=str(id)).update(status=slug)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
atomic = False
|
||||
|
||||
dependencies = [
|
||||
('ipam', '0029_3569_ipaddress_fields'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
|
||||
# VLAN.status
|
||||
migrations.AlterField(
|
||||
model_name='vlan',
|
||||
name='status',
|
||||
field=models.CharField(default='active', max_length=50),
|
||||
),
|
||||
migrations.RunPython(
|
||||
code=vlan_status_to_slug
|
||||
),
|
||||
|
||||
]
|
Reference in New Issue
Block a user