forked from uncloud/uncloud
Entry point /beta/vm/ works for creating VM + order
This commit is contained in:
parent
9ef5309b91
commit
028f1ebe6e
5 changed files with 28 additions and 38 deletions
|
|
@ -855,6 +855,11 @@ class Order(models.Model):
|
|||
recurring_price=recurring_price,
|
||||
description=description)
|
||||
|
||||
def __str__(self):
|
||||
return "Order {} created at {}, {}->{}, recurring period {}".format(
|
||||
self.uuid, self.creation_date,
|
||||
self.starting_date, self.ending_date,
|
||||
self.recurring_period)
|
||||
|
||||
|
||||
class OrderRecord(models.Model):
|
||||
|
|
@ -925,23 +930,26 @@ class Product(UncloudModel):
|
|||
# First time saving - create an order
|
||||
if not self.order:
|
||||
billing_address = BillingAddress.get_preferred_address_for(self.owner)
|
||||
print(billing_address)
|
||||
|
||||
if not billing_address:
|
||||
raise ValidationError("Cannot order without a billing address")
|
||||
|
||||
self.order = Order(owner=self.owner,
|
||||
self.order = Order.objects.create(owner=self.owner,
|
||||
billing_address=billing_address)
|
||||
|
||||
|
||||
super(Product, self).save(*args, **kwargs)
|
||||
print("in save op: {}".format(self))
|
||||
print(self.order)
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
# Make sure we only create records on creation.
|
||||
if being_created:
|
||||
record = OrderRecord(
|
||||
one_time_price=self.one_time_price,
|
||||
recurring_price=self.recurring_price,
|
||||
description=self.description)
|
||||
self.order.orderrecord_set.add(record, bulk=False)
|
||||
# # Make sure we only create records on creation.
|
||||
# if being_created:
|
||||
# record = OrderRecord(
|
||||
# one_time_price=self.one_time_price,
|
||||
# recurring_price=self.recurring_price,
|
||||
# description=self.description)
|
||||
# self.order.orderrecord_set.add(record, bulk=False)
|
||||
|
||||
@property
|
||||
def recurring_price(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue