forked from uncloud/uncloud
in between commit
Signed-off-by: Nico Schottelius <nico@nico-notebook.schottelius.org>
This commit is contained in:
parent
c9a941e290
commit
a091079677
2 changed files with 21 additions and 29 deletions
|
@ -48,8 +48,6 @@ class Command(BaseCommand):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
orders = []
|
|
||||||
|
|
||||||
# 25206
|
# 25206
|
||||||
vm25206 = VMProduct.objects.create(name="OpenNebula 25206",
|
vm25206 = VMProduct.objects.create(name="OpenNebula 25206",
|
||||||
cores=1,
|
cores=1,
|
||||||
|
@ -75,3 +73,16 @@ class Command(BaseCommand):
|
||||||
recurring_price = disk_price_2020(30, VMDiskType.CEPH_SSD) / 2,
|
recurring_price = disk_price_2020(30, VMDiskType.CEPH_SSD) / 2,
|
||||||
description = vm25206_ssd
|
description = vm25206_ssd
|
||||||
)
|
)
|
||||||
|
|
||||||
|
vm25206.cores = 2
|
||||||
|
vm25206.ram_in_gb = 8
|
||||||
|
vm25206.save()
|
||||||
|
|
||||||
|
order_vm_25206_growing = Order.objects.create(owner=user,
|
||||||
|
billing_address=addr,
|
||||||
|
starting_date=timezone.make_aware(datetime.datetime(2020,4,17)),
|
||||||
|
recurring_period=RecurringPeriod.PER_30D,
|
||||||
|
recurring_price = vm_price_2020(cpu=2, ram=8) / 2,
|
||||||
|
replaces=order_vm_25206,
|
||||||
|
description = "VM %s" % vm25206
|
||||||
|
)
|
||||||
|
|
|
@ -332,6 +332,8 @@ class Order(models.Model):
|
||||||
blank=True,
|
blank=True,
|
||||||
null=True)
|
null=True)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def count_billed(self):
|
def count_billed(self):
|
||||||
"""
|
"""
|
||||||
|
@ -535,6 +537,8 @@ class Bill(models.Model):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class BillRecord(models.Model):
|
class BillRecord(models.Model):
|
||||||
"""
|
"""
|
||||||
Entry of a bill, dynamically generated from an order.
|
Entry of a bill, dynamically generated from an order.
|
||||||
|
@ -595,8 +599,6 @@ class OrderRecord(models.Model):
|
||||||
###
|
###
|
||||||
# Products
|
# Products
|
||||||
|
|
||||||
# Abstract (= no database representation) class used as parent for products
|
|
||||||
# (e.g. uncloud_vm.models.VMProduct).
|
|
||||||
class Product(UncloudModel):
|
class Product(UncloudModel):
|
||||||
owner = models.ForeignKey(get_user_model(),
|
owner = models.ForeignKey(get_user_model(),
|
||||||
on_delete=models.CASCADE,
|
on_delete=models.CASCADE,
|
||||||
|
@ -604,15 +606,15 @@ class Product(UncloudModel):
|
||||||
|
|
||||||
description = "Generic Product"
|
description = "Generic Product"
|
||||||
|
|
||||||
status = models.CharField(max_length=32,
|
|
||||||
choices=UncloudStatus.choices,
|
|
||||||
default=UncloudStatus.AWAITING_PAYMENT)
|
|
||||||
|
|
||||||
order = models.ForeignKey(Order,
|
order = models.ForeignKey(Order,
|
||||||
on_delete=models.CASCADE,
|
on_delete=models.CASCADE,
|
||||||
editable=False,
|
editable=False,
|
||||||
null=True)
|
null=True)
|
||||||
|
|
||||||
|
status = models.CharField(max_length=32,
|
||||||
|
choices=UncloudStatus.choices,
|
||||||
|
default=UncloudStatus.AWAITING_PAYMENT)
|
||||||
|
|
||||||
# Default period for all products
|
# Default period for all products
|
||||||
default_recurring_period = RecurringPeriod.PER_30D
|
default_recurring_period = RecurringPeriod.PER_30D
|
||||||
|
|
||||||
|
@ -638,14 +640,6 @@ class Product(UncloudModel):
|
||||||
|
|
||||||
super().save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
# # Make sure we only create records on creation.
|
|
||||||
# if being_created:
|
|
||||||
# record = OrderRecord(
|
|
||||||
# one_time_price=self.one_time_price,
|
|
||||||
# recurring_price=self.recurring_price,
|
|
||||||
# description=self.description)
|
|
||||||
# self.order.orderrecord_set.add(record, bulk=False)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def recurring_price(self):
|
def recurring_price(self):
|
||||||
pass # To be implemented in child.
|
pass # To be implemented in child.
|
||||||
|
@ -736,16 +730,3 @@ class Product(UncloudModel):
|
||||||
else:
|
else:
|
||||||
# FIXME: use the right type of exception here!
|
# FIXME: use the right type of exception here!
|
||||||
raise Exception("Did not implement the discounter for this case")
|
raise Exception("Did not implement the discounter for this case")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Interesting snippets
|
|
||||||
|
|
||||||
# # Trigger initial bill generation at order creation.
|
|
||||||
# def save(self, *args, **kwargs):
|
|
||||||
# if self.ending_date and self.ending_date < self.starting_date:
|
|
||||||
# raise ValidationError("End date cannot be before starting date")
|
|
||||||
|
|
||||||
# super().save(*args, **kwargs)
|
|
||||||
|
|
||||||
# Bill.generate_for(self.starting_date.year, self.starting_date.month, self.owner)
|
|
||||||
|
|
Loading…
Reference in a new issue