Attempt to merge master into task/3747/multiple_cards_support

This commit is contained in:
PCoder 2018-06-12 08:13:48 +02:00
commit cf00ff6bd8
269 changed files with 8500 additions and 29554 deletions

View file

@ -20,6 +20,8 @@ from utils.mailer import BaseEmail
from utils.models import BillingAddress
from utils.stripe_utils import StripeUtils
from .models import VMPricing
logger = get_task_logger(__name__)
@ -57,7 +59,8 @@ def create_vm_task(self, vm_template_id, user, specs, template,
"Running create_vm_task on {}".format(current_task.request.hostname))
vm_id = None
try:
final_price = specs.get('price')
final_price = (specs.get('total_price') if 'total_price' in specs
else specs.get('price'))
billing_address = BillingAddress(
cardholder_name=billing_address_data['cardholder_name'],
street_address=billing_address_data['street_address'],
@ -95,17 +98,22 @@ def create_vm_task(self, vm_template_id, user, specs, template,
if vm_id is None:
raise Exception("Could not create VM")
vm_pricing = VMPricing.get_vm_pricing_by_name(
name=specs['pricing_name']
) if 'pricing_name' in specs else VMPricing.get_default_pricing()
# Create a Hosting Order
order = HostingOrder.create(
price=final_price,
vm_id=vm_id,
customer=customer,
billing_address=billing_address
billing_address=billing_address,
vm_pricing=vm_pricing
)
# Create a Hosting Bill
HostingBill.create(
customer=customer, billing_address=billing_address)
customer=customer, billing_address=billing_address
)
# Create Billing Address for User if he does not have one
if not customer.user.billing_addresses.count():
@ -135,12 +143,16 @@ def create_vm_task(self, vm_template_id, user, specs, template,
'cores': specs.get('cpu'),
'memory': specs.get('memory'),
'storage': specs.get('disk_size'),
'price': specs.get('price'),
'price': final_price,
'template': template.get('name'),
'vm_name': vm.get('name'),
'vm_id': vm['vm_id'],
'order_id': order.id
}
if 'pricing_name' in specs:
context['pricing'] = str(VMPricing.get_vm_pricing_by_name(
name=specs['pricing_name']
))
email_data = {
'subject': settings.DCL_TEXT + " Order from %s" % context['email'],
'from_email': settings.DCL_SUPPORT_FROM_ADDRESS,