Compute vm price on post of dcl index and set in session

This commit is contained in:
PCoder 2017-09-28 04:22:15 +05:30
parent e215a85a4d
commit 39cb930326

View file

@ -262,11 +262,13 @@ class IndexView(CreateView):
extra_tags='storage') extra_tags='storage')
return HttpResponseRedirect( return HttpResponseRedirect(
reverse('datacenterlight:index') + "#order_form") reverse('datacenterlight:index') + "#order_form")
amount_to_be_charged = get_vm_price(cpu=cores, memory=memory,
disk_size=storage)
specs = { specs = {
'cpu': cores, 'cpu': cores,
'memory': memory, 'memory': memory,
'disk_size': storage, 'disk_size': storage,
'price': amount_to_be_charged
} }
request.session['specs'] = specs request.session['specs'] = specs
request.session['template'] = template_data request.session['template'] = template_data
@ -477,9 +479,7 @@ class OrderConfirmationView(DetailView):
cpu = specs.get('cpu') cpu = specs.get('cpu')
memory = specs.get('memory') memory = specs.get('memory')
disk_size = specs.get('disk_size') disk_size = specs.get('disk_size')
amount_to_be_charged = get_vm_price(cpu=cpu, memory=memory, amount_to_be_charged = specs.get('price')
disk_size=disk_size)
specs['price'] = amount_to_be_charged
plan_name = StripeUtils.get_stripe_plan_name(cpu=cpu, plan_name = StripeUtils.get_stripe_plan_name(cpu=cpu,
memory=memory, memory=memory,
disk_size=disk_size) disk_size=disk_size)