mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
PowerFeed.supply to slug (#3569)
This commit is contained in:
@@ -6,6 +6,11 @@ POWERFEED_TYPE_CHOICES = (
|
||||
(2, 'redundant'),
|
||||
)
|
||||
|
||||
POWERFEED_SUPPLY_CHOICES = (
|
||||
(1, 'ac'),
|
||||
(2, 'dc'),
|
||||
)
|
||||
|
||||
|
||||
def powerfeed_type_to_slug(apps, schema_editor):
|
||||
PowerFeed = apps.get_model('dcim', 'PowerFeed')
|
||||
@@ -13,6 +18,12 @@ def powerfeed_type_to_slug(apps, schema_editor):
|
||||
PowerFeed.objects.filter(type=id).update(type=slug)
|
||||
|
||||
|
||||
def powerfeed_supply_to_slug(apps, schema_editor):
|
||||
PowerFeed = apps.get_model('dcim', 'PowerFeed')
|
||||
for id, slug in POWERFEED_SUPPLY_CHOICES:
|
||||
PowerFeed.objects.filter(supply=id).update(supply=slug)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
atomic = False
|
||||
|
||||
@@ -22,7 +33,7 @@ class Migration(migrations.Migration):
|
||||
|
||||
operations = [
|
||||
|
||||
# Cable.type
|
||||
# PowerFeed.type
|
||||
migrations.AlterField(
|
||||
model_name='powerfeed',
|
||||
name='type',
|
||||
@@ -32,4 +43,14 @@ class Migration(migrations.Migration):
|
||||
code=powerfeed_type_to_slug
|
||||
),
|
||||
|
||||
# PowerFeed.supply
|
||||
migrations.AlterField(
|
||||
model_name='powerfeed',
|
||||
name='supply',
|
||||
field=models.CharField(blank=True, max_length=50),
|
||||
),
|
||||
migrations.RunPython(
|
||||
code=powerfeed_supply_to_slug
|
||||
),
|
||||
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user