2020-02-28 13:46:33 +00:00
|
|
|
import uuid
|
|
|
|
|
|
|
|
from django.db import models
|
|
|
|
from uncloud_pay.models import Product, RecurringPeriod
|
|
|
|
from uncloud_vm.models import VMProduct
|
|
|
|
|
|
|
|
class MatrixServiceProduct(Product):
|
|
|
|
monthly_managment_fee = 20
|
|
|
|
setup_fee = 30
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
def recurring_price(self, recurring_period=RecurringPeriod.PER_MONTH):
|
|
|
|
if recurring_period == RecurringPeriod.PER_MONTH:
|
|
|
|
return monthly_managment_fee + vm.recurring_price(RecurringPeriod.PER_MONTH)
|
|
|
|
else:
|
|
|
|
raise Exception('Invalid recurring period for VM Product pricing.')
|
2020-02-28 15:26:45 +00:00
|
|
|
|
|
|
|
def setup_fee(self):
|
|
|
|
return setup_fee
|