2020-02-28 13:46:33 +00:00
|
|
|
import uuid
|
|
|
|
|
|
|
|
from django.db import models
|
|
|
|
from uncloud_pay.models import Product, RecurringPeriod
|
2020-03-09 15:37:56 +00:00
|
|
|
from uncloud_vm.models import VMProduct, VMDiskImageProduct
|
2020-02-28 13:46:33 +00:00
|
|
|
|
|
|
|
class MatrixServiceProduct(Product):
|
|
|
|
monthly_managment_fee = 20
|
|
|
|
|
|
|
|
description = "Managed Matrix HomeServer"
|
2020-02-28 15:26:45 +00:00
|
|
|
|
|
|
|
# Specific to Matrix-as-a-Service
|
2020-02-28 13:46:33 +00:00
|
|
|
vm = models.ForeignKey(
|
|
|
|
VMProduct, on_delete=models.CASCADE
|
|
|
|
)
|
2020-02-28 15:26:45 +00:00
|
|
|
domain = models.CharField(max_length=255, default='domain.tld')
|
2020-02-28 13:46:33 +00:00
|
|
|
|
2020-04-13 10:00:59 +00:00
|
|
|
# Default recurring price is PER_MONT, see Product class.
|
|
|
|
def recurring_price(self):
|
|
|
|
return self.monthly_managment_fee
|
2020-02-28 15:26:45 +00:00
|
|
|
|
2020-03-09 15:37:56 +00:00
|
|
|
@staticmethod
|
|
|
|
def base_image():
|
|
|
|
# TODO: find a way to safely reference debian 10 image.
|
|
|
|
return VMDiskImageProduct.objects.get(uuid="93e564c5-adb3-4741-941f-718f76075f02")
|
|
|
|
|
2020-03-03 09:51:16 +00:00
|
|
|
@staticmethod
|
|
|
|
def allowed_recurring_periods():
|
|
|
|
return list(filter(
|
|
|
|
lambda pair: pair[0] in [RecurringPeriod.PER_MONTH],
|
|
|
|
RecurringPeriod.choices))
|
|
|
|
|
|
|
|
@property
|
2020-03-03 10:27:35 +00:00
|
|
|
def one_time_price(self):
|
2020-03-03 09:51:16 +00:00
|
|
|
return 30
|