mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
86 lines
2.3 KiB
Python
86 lines
2.3 KiB
Python
from django.db import migrations, models
|
|
|
|
|
|
PORT_TYPE_CHOICES = (
|
|
(1000, '8p8c'),
|
|
(1100, '110-punch'),
|
|
(1200, 'bnc'),
|
|
(2000, 'st'),
|
|
(2100, 'sc'),
|
|
(2110, 'sc-apc'),
|
|
(2200, 'fc'),
|
|
(2300, 'lc'),
|
|
(2310, 'lc-apc'),
|
|
(2400, 'mtrj'),
|
|
(2500, 'mpo'),
|
|
(2600, 'lsh'),
|
|
(2610, 'lsh-apc'),
|
|
)
|
|
|
|
|
|
def frontporttemplate_type_to_slug(apps, schema_editor):
|
|
FrontPortTemplate = apps.get_model('dcim', 'FrontPortTemplate')
|
|
for id, slug in PORT_TYPE_CHOICES:
|
|
FrontPortTemplate.objects.filter(type=id).update(type=slug)
|
|
|
|
|
|
def rearporttemplate_type_to_slug(apps, schema_editor):
|
|
RearPortTemplate = apps.get_model('dcim', 'RearPortTemplate')
|
|
for id, slug in PORT_TYPE_CHOICES:
|
|
RearPortTemplate.objects.filter(type=id).update(type=slug)
|
|
|
|
|
|
def frontport_type_to_slug(apps, schema_editor):
|
|
FrontPort = apps.get_model('dcim', 'FrontPort')
|
|
for id, slug in PORT_TYPE_CHOICES:
|
|
FrontPort.objects.filter(type=id).update(type=slug)
|
|
|
|
|
|
def rearport_type_to_slug(apps, schema_editor):
|
|
RearPort = apps.get_model('dcim', 'RearPort')
|
|
for id, slug in PORT_TYPE_CHOICES:
|
|
RearPort.objects.filter(type=id).update(type=slug)
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
atomic = False
|
|
|
|
dependencies = [
|
|
('dcim', '0082_3569_interface_fields'),
|
|
]
|
|
|
|
operations = [
|
|
migrations.AlterField(
|
|
model_name='frontporttemplate',
|
|
name='type',
|
|
field=models.CharField(max_length=50),
|
|
),
|
|
migrations.RunPython(
|
|
code=frontporttemplate_type_to_slug
|
|
),
|
|
migrations.AlterField(
|
|
model_name='rearporttemplate',
|
|
name='type',
|
|
field=models.CharField(max_length=50),
|
|
),
|
|
migrations.RunPython(
|
|
code=rearporttemplate_type_to_slug
|
|
),
|
|
migrations.AlterField(
|
|
model_name='frontport',
|
|
name='type',
|
|
field=models.CharField(max_length=50),
|
|
),
|
|
migrations.RunPython(
|
|
code=frontport_type_to_slug
|
|
),
|
|
migrations.AlterField(
|
|
model_name='rearport',
|
|
name='type',
|
|
field=models.CharField(max_length=50),
|
|
),
|
|
migrations.RunPython(
|
|
code=rearport_type_to_slug
|
|
),
|
|
]
|