fix tests for Product()
Signed-off-by: Nico Schottelius <nico@nico-notebook.schottelius.org>
This commit is contained in:
parent
0dd1093812
commit
70c450afc8
1 changed files with 15 additions and 12 deletions
|
@ -645,7 +645,6 @@ class Product(UncloudModel):
|
||||||
if not recurring_period:
|
if not recurring_period:
|
||||||
recurring_period = self.default_recurring_period
|
recurring_period = self.default_recurring_period
|
||||||
|
|
||||||
one_time_order = None
|
|
||||||
|
|
||||||
if self.one_time_price > 0:
|
if self.one_time_price > 0:
|
||||||
one_time_order = Order.objects.create(owner=self.owner,
|
one_time_order = Order.objects.create(owner=self.owner,
|
||||||
|
@ -654,9 +653,12 @@ class Product(UncloudModel):
|
||||||
price=self.one_time_price,
|
price=self.one_time_price,
|
||||||
recurring_period=RecurringPeriod.ONE_TIME,
|
recurring_period=RecurringPeriod.ONE_TIME,
|
||||||
description=str(self))
|
description=str(self))
|
||||||
|
else:
|
||||||
|
one_time_order = None
|
||||||
|
|
||||||
if recurring_period != RecurringPeriod.ONE_TIME:
|
if recurring_period != RecurringPeriod.ONE_TIME:
|
||||||
|
print("not one time")
|
||||||
|
|
||||||
if one_time_order:
|
if one_time_order:
|
||||||
recurring_order = Order.objects.create(owner=self.owner,
|
recurring_order = Order.objects.create(owner=self.owner,
|
||||||
billing_address=billing_address,
|
billing_address=billing_address,
|
||||||
|
@ -699,12 +701,13 @@ class Product(UncloudModel):
|
||||||
self.order = new_order
|
self.order = new_order
|
||||||
|
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
# def save(self, *args, **kwargs):
|
||||||
# Create order if there is none already
|
# if not self.order:
|
||||||
if not self.order:
|
# raise ValidationError("Cannot create product without order")
|
||||||
self.create_or_update_order()
|
|
||||||
|
|
||||||
super().save(*args, **kwargs)
|
# self.create_or_update_order()
|
||||||
|
|
||||||
|
# super().save(*args, **kwargs)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def recurring_price(self):
|
def recurring_price(self):
|
||||||
|
|
Loading…
Reference in a new issue