forked from uncloud/uncloud
Add naive GenericServiceProduct
This commit is contained in:
parent
83a0ca0e4e
commit
c57780fb4d
6 changed files with 146 additions and 5 deletions
|
|
@ -1,8 +1,9 @@
|
|||
import uuid
|
||||
|
||||
from django.db import models
|
||||
from uncloud_pay.models import Product, RecurringPeriod
|
||||
from uncloud_pay.models import Product, RecurringPeriod, AMOUNT_MAX_DIGITS, AMOUNT_DECIMALS
|
||||
from uncloud_vm.models import VMProduct, VMDiskImageProduct
|
||||
from django.core.validators import MinValueValidator
|
||||
|
||||
class MatrixServiceProduct(Product):
|
||||
monthly_managment_fee = 20
|
||||
|
|
@ -33,3 +34,30 @@ class MatrixServiceProduct(Product):
|
|||
@property
|
||||
def one_time_price(self):
|
||||
return 30
|
||||
|
||||
class GenericServiceProduct(Product):
|
||||
custom_description = models.TextField()
|
||||
custom_recurring_price = models.DecimalField(default=0.0,
|
||||
max_digits=AMOUNT_MAX_DIGITS,
|
||||
decimal_places=AMOUNT_DECIMALS,
|
||||
validators=[MinValueValidator(0)])
|
||||
custom_one_time_price = models.DecimalField(default=0.0,
|
||||
max_digits=AMOUNT_MAX_DIGITS,
|
||||
decimal_places=AMOUNT_DECIMALS,
|
||||
validators=[MinValueValidator(0)])
|
||||
|
||||
@property
|
||||
def recurring_price(self):
|
||||
return self.custom_recurring_price
|
||||
|
||||
@property
|
||||
def description(self):
|
||||
return self.custom_description
|
||||
|
||||
@property
|
||||
def one_time_price(self):
|
||||
return self.custom_one_time_price
|
||||
|
||||
@staticmethod
|
||||
def allowed_recurring_periods():
|
||||
return RecurringPeriod.choices
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue