Save order specifications in HostingOrder also

This commit is contained in:
PCoder 2018-07-01 18:33:10 +02:00
commit 900f014d92
3 changed files with 59 additions and 3 deletions

View file

@ -1,12 +1,12 @@
from django.contrib.sites.models import Site
from datacenterlight.tasks import create_vm_task
from hosting.models import HostingOrder, HostingBill
from hosting.models import HostingOrder, HostingBill, OrderSpecifications
from membership.models import StripeCustomer
from utils.forms import UserBillingAddressForm
from utils.models import BillingAddress
from .cms_models import CMSIntegration
from .models import VMPricing
from .models import VMPricing, VMTemplate
def get_cms_integration(name):
@ -53,6 +53,13 @@ def create_vm(billing_address_data, stripe_customer_id, specs,
vm_pricing=vm_pricing
)
order_specs_obj, obj_created = OrderSpecifications.objects.get_or_create(
vm_template=VMTemplate.objects.get(vm_template_id),
cores=specs['cpu'], memory=specs['memory'], ssd_size=specs['disk_size']
)
order.order_specs = order_specs_obj
order.save()
# Create a Hosting Bill
HostingBill.create(customer=customer, billing_address=billing_address)