[product] migrate orders to ManyToManyField
This commit is contained in:
parent
8df1d8dc7c
commit
2b29e300dd
2 changed files with 5 additions and 19 deletions
|
|
@ -615,19 +615,6 @@ class Product(UncloudModel):
|
|||
description = "Generic Product"
|
||||
|
||||
orders = models.ManyToManyField(Order)
|
||||
# one_time_order = models.ForeignKey(Order,
|
||||
# on_delete=models.CASCADE,
|
||||
# editable=True,
|
||||
# null=True,
|
||||
# related_name='product_one_time')
|
||||
|
||||
# recurring_order = models.ForeignKey(Order,
|
||||
# on_delete=models.CASCADE,
|
||||
# editable=True,
|
||||
# null=True,
|
||||
# related_name='product_recurring')
|
||||
|
||||
# FIXME: editable=True -> is in the admin, but also editable in DRF
|
||||
|
||||
status = models.CharField(max_length=32,
|
||||
choices=UncloudStatus.choices,
|
||||
|
|
@ -656,6 +643,7 @@ class Product(UncloudModel):
|
|||
price=self.one_time_price,
|
||||
recurring_period=RecurringPeriod.ONE_TIME,
|
||||
description=str(self))
|
||||
self.orders.add(one_time_order)
|
||||
else:
|
||||
one_time_order = None
|
||||
|
||||
|
|
@ -675,6 +663,7 @@ class Product(UncloudModel):
|
|||
price=self.recurring_price,
|
||||
recurring_period=recurring_period,
|
||||
description=str(self))
|
||||
self.orders.add(recurring_order)
|
||||
|
||||
|
||||
def create_or_update_order(self, when_to_start=None, recurring_period=None):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue