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

PowerFeed.phase to slug (#3569)

This commit is contained in:
Jeremy Stretch
2019-11-25 21:14:04 -05:00
parent bb8b012397
commit 2dc07ca30d
6 changed files with 50 additions and 18 deletions

View File

@@ -11,6 +11,11 @@ POWERFEED_SUPPLY_CHOICES = (
(2, 'dc'),
)
POWERFEED_PHASE_CHOICES = (
(1, 'single-phase'),
(3, 'three-phase'),
)
def powerfeed_type_to_slug(apps, schema_editor):
PowerFeed = apps.get_model('dcim', 'PowerFeed')
@@ -24,6 +29,12 @@ def powerfeed_supply_to_slug(apps, schema_editor):
PowerFeed.objects.filter(supply=id).update(supply=slug)
def powerfeed_phase_to_slug(apps, schema_editor):
PowerFeed = apps.get_model('dcim', 'PowerFeed')
for id, slug in POWERFEED_PHASE_CHOICES:
PowerFeed.objects.filter(phase=id).update(phase=slug)
class Migration(migrations.Migration):
atomic = False
@@ -53,4 +64,14 @@ class Migration(migrations.Migration):
code=powerfeed_supply_to_slug
),
# PowerFeed.phase
migrations.AlterField(
model_name='powerfeed',
name='phase',
field=models.CharField(blank=True, max_length=50),
),
migrations.RunPython(
code=powerfeed_phase_to_slug
),
]