Rename OrderSpecifications to OrderDetail

This commit is contained in:
PCoder 2018-07-01 22:30:23 +02:00
parent 00cb1de75d
commit 44900f6a48
3 changed files with 10 additions and 10 deletions

View file

@ -1,7 +1,7 @@
from django.contrib.sites.models import Site from django.contrib.sites.models import Site
from datacenterlight.tasks import create_vm_task from datacenterlight.tasks import create_vm_task
from hosting.models import HostingOrder, HostingBill, OrderSpecifications from hosting.models import HostingOrder, HostingBill, OrderDetail
from membership.models import StripeCustomer from membership.models import StripeCustomer
from utils.forms import UserBillingAddressForm from utils.forms import UserBillingAddressForm
from utils.models import BillingAddress from utils.models import BillingAddress
@ -53,13 +53,13 @@ def create_vm(billing_address_data, stripe_customer_id, specs,
vm_pricing=vm_pricing vm_pricing=vm_pricing
) )
order_specs_obj, obj_created = OrderSpecifications.objects.get_or_create( order_detail_obj, obj_created = OrderDetail.objects.get_or_create(
vm_template=VMTemplate.objects.get( vm_template=VMTemplate.objects.get(
opennebula_vm_template_id=vm_template_id opennebula_vm_template_id=vm_template_id
), ),
cores=specs['cpu'], memory=specs['memory'], ssd_size=specs['disk_size'] cores=specs['cpu'], memory=specs['memory'], ssd_size=specs['disk_size']
) )
order.order_specs = order_specs_obj order.order_detail = order_detail_obj
order.save() order.save()
# Create a Hosting Bill # Create a Hosting Bill

View file

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2018-07-01 17:18 # Generated by Django 1.9.4 on 2018-07-01 20:28
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations, models
@ -16,7 +16,7 @@ class Migration(migrations.Migration):
operations = [ operations = [
migrations.CreateModel( migrations.CreateModel(
name='OrderSpecifications', name='OrderDetail',
fields=[ fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('cores', models.IntegerField(default=0)), ('cores', models.IntegerField(default=0)),
@ -29,7 +29,7 @@ class Migration(migrations.Migration):
), ),
migrations.AddField( migrations.AddField(
model_name='hostingorder', model_name='hostingorder',
name='order_specs', name='order_detail',
field=models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.SET_NULL, to='hosting.OrderSpecifications'), field=models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.SET_NULL, to='hosting.OrderDetail'),
), ),
] ]

View file

@ -41,7 +41,7 @@ class HostingPlan(models.Model):
return price return price
class OrderSpecifications(AssignPermissionsMixin, models.Model): class OrderDetail(AssignPermissionsMixin, models.Model):
vm_template = models.ForeignKey( vm_template = models.ForeignKey(
VMTemplate, blank=True, null=True, default=None, VMTemplate, blank=True, null=True, default=None,
on_delete=models.SET_NULL on_delete=models.SET_NULL
@ -73,8 +73,8 @@ class HostingOrder(AssignPermissionsMixin, models.Model):
price = models.FloatField() price = models.FloatField()
subscription_id = models.CharField(max_length=100, null=True) subscription_id = models.CharField(max_length=100, null=True)
vm_pricing = models.ForeignKey(VMPricing) vm_pricing = models.ForeignKey(VMPricing)
order_specs = models.ForeignKey( order_detail = models.ForeignKey(
OrderSpecifications, null=True, blank=True, default=None, OrderDetail, null=True, blank=True, default=None,
on_delete=models.SET_NULL on_delete=models.SET_NULL
) )