begin refactor product to user orders instead of single order
Signed-off-by: Nico Schottelius <nico@nico-notebook.schottelius.org>
This commit is contained in:
parent
ef02cb61fd
commit
8df1d8dc7c
10 changed files with 224 additions and 90 deletions
|
|
@ -58,13 +58,10 @@ class VMProduct(Product):
|
|||
VMCluster, on_delete=models.CASCADE, editable=False, blank=True, null=True
|
||||
)
|
||||
|
||||
# VM-specific. The name is only intended for customers: it's a pain to
|
||||
# remember IDs (speaking from experience as ungleich customer)!
|
||||
name = models.CharField(max_length=32, blank=True, null=True)
|
||||
cores = models.IntegerField()
|
||||
ram_in_gb = models.FloatField()
|
||||
|
||||
# Default recurring price is PER_MONTH, see uncloud_pay.models.Product.
|
||||
@property
|
||||
def recurring_price(self):
|
||||
return self.cores * 3 + self.ram_in_gb * 4
|
||||
|
|
@ -83,14 +80,7 @@ class VMProduct(Product):
|
|||
|
||||
|
||||
def __str__(self):
|
||||
name = f"{self.id}"
|
||||
|
||||
if self.name:
|
||||
name = f"{self.id} ({self.name})"
|
||||
|
||||
return "VM {}: {} cores {} gb ram".format(name,
|
||||
self.cores,
|
||||
self.ram_in_gb)
|
||||
return f"VM id={self.id},name={self.name},cores={self.cores},ram_in_gb={self.ram_in_gb}"
|
||||
|
||||
|
||||
class VMWithOSProduct(VMProduct):
|
||||
|
|
@ -165,7 +155,7 @@ class VMDiskProduct(Product):
|
|||
default=VMDiskType.CEPH_SSD)
|
||||
|
||||
def __str__(self):
|
||||
return f"Disk {self.size_in_gb}GB ({self.disk_type}) for VM '{self.vm.name}'"
|
||||
return f"Disk {self.size_in_gb}GB ({self.disk_type}) for {self.vm}"
|
||||
|
||||
@property
|
||||
def recurring_price(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue