Cleanup code so that *most* test work again

Still need to solve the downgrade test
This commit is contained in:
Nico Schottelius 2020-11-15 15:43:11 +01:00
commit 0b1c2cc168
8 changed files with 40 additions and 2254 deletions

View file

@ -209,7 +209,7 @@ class PaymentMethod(models.Model):
pass
# See https://docs.djangoproject.com/en/dev/ref/models/fields/#field-choices-enum-types
class RecurringPeriodChoices(models.IntegerChoices):
class RecurringPeriodDefaultChoices(models.IntegerChoices):
"""
This is an old class and being superseeded by the database model below
"""
@ -234,7 +234,7 @@ class RecurringPeriod(models.Model):
@classmethod
def populate_db_defaults(cls):
for (seconds, name) in RecurringPeriodChoices.choices:
for (seconds, name) in RecurringPeriodDefaultChoices.choices:
obj, created = cls.objects.get_or_create(name=name,
defaults={ 'duration_seconds': seconds })
@ -470,7 +470,7 @@ class Product(models.Model):
@property
def recurring_orders(self):
return self.orders.order_by('id').exclude(recurring_period=RecurringPeriod.ONE_TIME)
return self.orders.order_by('id').exclude(recurring_period=RecurringPeriod.objects.get(name="ONE_TIME"))
@property
def last_recurring_order(self):
@ -478,7 +478,7 @@ class Product(models.Model):
@property
def one_time_orders(self):
return self.orders.order_by('id').filter(recurring_period=RecurringPeriod.ONE_TIME)
return self.orders.order_by('id').filter(recurring_period=RecurringPeriod.objects.get(name="ONE_TIME"))
@property
def last_one_time_order(self):
@ -503,13 +503,13 @@ class Product(models.Model):
billing_address=billing_address,
starting_date=when_to_start,
price=self.one_time_price,
recurring_period=RecurringPeriod.ONE_TIME,
recurring_period=RecurringPeriod.objects.get(name="ONE_TIME"),
description=str(self))
self.orders.add(one_time_order)
else:
one_time_order = None
if recurring_period != RecurringPeriod.ONE_TIME:
if recurring_period != RecurringPeriod.objects.get(name="ONE_TIME"):
if one_time_order:
recurring_order = Order.objects.create(owner=self.owner,
billing_address=billing_address,
@ -827,7 +827,7 @@ class Order(models.Model):
@property
def is_recurring(self):
return not self.recurring_period == RecurringPeriod.ONE_TIME
return not self.recurring_period == RecurringPeriod.objects.get(name="ONE_TIME")
@property
def is_one_time(self):
@ -857,6 +857,8 @@ class Order(models.Model):
(new_order.one_time_price, new_order.recurring_price, new_order.config) = new_order.calculate_prices_and_config()
new_order.replaces = self
new_order.save()