forked from uncloud/uncloud
Rename ungleich_service into uncloud_service
This commit is contained in:
parent
e67bd03997
commit
1a58508f8b
14 changed files with 8 additions and 61 deletions
37
uncloud_django_based/uncloud/uncloud_service/models.py
Normal file
37
uncloud_django_based/uncloud/uncloud_service/models.py
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import uuid
|
||||
|
||||
from django.db import models
|
||||
from uncloud_pay.models import Product, RecurringPeriod
|
||||
from uncloud_vm.models import VMProduct, VMDiskImageProduct
|
||||
|
||||
class MatrixServiceProduct(Product):
|
||||
monthly_managment_fee = 20
|
||||
|
||||
description = "Managed Matrix HomeServer"
|
||||
|
||||
# Specific to Matrix-as-a-Service
|
||||
vm = models.ForeignKey(
|
||||
VMProduct, on_delete=models.CASCADE
|
||||
)
|
||||
domain = models.CharField(max_length=255, default='domain.tld')
|
||||
|
||||
def recurring_price(self, recurring_period=RecurringPeriod.PER_MONTH):
|
||||
if recurring_period == RecurringPeriod.PER_MONTH:
|
||||
return self.monthly_managment_fee
|
||||
else:
|
||||
raise Exception('Invalid recurring period for VM Product pricing.')
|
||||
|
||||
@staticmethod
|
||||
def base_image():
|
||||
# TODO: find a way to safely reference debian 10 image.
|
||||
return VMDiskImageProduct.objects.get(uuid="93e564c5-adb3-4741-941f-718f76075f02")
|
||||
|
||||
@staticmethod
|
||||
def allowed_recurring_periods():
|
||||
return list(filter(
|
||||
lambda pair: pair[0] in [RecurringPeriod.PER_MONTH],
|
||||
RecurringPeriod.choices))
|
||||
|
||||
@property
|
||||
def one_time_price(self):
|
||||
return 30
|
||||
Loading…
Add table
Add a link
Reference in a new issue