Add VMPricing init migration

This commit is contained in:
PCoder 2018-04-09 21:34:09 +02:00
parent 4d6fdf2de9
commit 76c9b20cc9

View file

@ -0,0 +1,48 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2018-04-09 19:28
from __future__ import unicode_literals
from django.db import migrations
DEFAULT_VMPRICING_NAME='default'
def create_default_pricing(apps, schema_editor):
"""
Create default pricing
:param apps:
:param schema_editor:
:return:
"""
VMPricing = apps.get_model('datacenterlight', 'VMPricing')
if not VMPricing.objects.count():
vm_pricing = VMPricing(
name=DEFAULT_VMPRICING_NAME,
vat_inclusive=True,
cores_unit_price=5,
ram_unit_price=2,
ssd_unit_price=0.6,
hdd_unit_price=0.1,
)
vm_pricing.save()
def undo_vm_pricing(apps, schema_editor):
"""Deleting all entries for this model"""
VMPricing = apps.get_model("datacenterlight", "VMPricing")
VMPricing.objects.all().delete()
class Migration(migrations.Migration):
dependencies = [
('datacenterlight', '0019_auto_20180409_1923'),
]
operations = [
migrations.RunPython(
create_default_pricing,
reverse_code=undo_vm_pricing
),
]