fix tests for Product()

Signed-off-by: Nico Schottelius <nico@nico-notebook.schottelius.org>
This commit is contained in:
Nico Schottelius 2020-08-09 11:44:22 +02:00
parent 0dd1093812
commit 70c450afc8
1 changed files with 15 additions and 12 deletions

View File

@ -645,18 +645,20 @@ class Product(UncloudModel):
if not recurring_period:
recurring_period = self.default_recurring_period
one_time_order = None
if self.one_time_price > 0:
one_time_order = Order.objects.create(owner=self.owner,
billing_address=billing_address,
starting_date=when_to_start,
price=self.one_time_price,
recurring_period=RecurringPeriod.ONE_TIME,
description=str(self))
billing_address=billing_address,
starting_date=when_to_start,
price=self.one_time_price,
recurring_period=RecurringPeriod.ONE_TIME,
description=str(self))
else:
one_time_order = None
if recurring_period != RecurringPeriod.ONE_TIME:
print("not one time")
if one_time_order:
recurring_order = Order.objects.create(owner=self.owner,
billing_address=billing_address,
@ -699,12 +701,13 @@ class Product(UncloudModel):
self.order = new_order
def save(self, *args, **kwargs):
# Create order if there is none already
if not self.order:
self.create_or_update_order()
# def save(self, *args, **kwargs):
# if not self.order:
# raise ValidationError("Cannot create product without order")
super().save(*args, **kwargs)
# self.create_or_update_order()
# super().save(*args, **kwargs)
@property
def recurring_price(self):