From 70c450afc8984bab59b8eb622bb99e19d9b59306 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 9 Aug 2020 11:44:22 +0200 Subject: [PATCH] fix tests for Product() Signed-off-by: Nico Schottelius --- uncloud_pay/models.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/uncloud_pay/models.py b/uncloud_pay/models.py index 8023bf7..4005908 100644 --- a/uncloud_pay/models.py +++ b/uncloud_pay/models.py @@ -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):