diff --git a/uncloud/uncloud_pay/models.py b/uncloud/uncloud_pay/models.py index 8e41e24..f5639c4 100644 --- a/uncloud/uncloud_pay/models.py +++ b/uncloud/uncloud_pay/models.py @@ -163,5 +163,9 @@ class Product(models.Model): def recurring_price(self, recurring_period=RecurringPeriod.PER_MONTH): pass # To be implemented in child. + @property + def setup_fee(self): + return 0 + class Meta: abstract = True diff --git a/uncloud/uncloud_vm/serializers.py b/uncloud/uncloud_vm/serializers.py index cb60cfe..4257a03 100644 --- a/uncloud/uncloud_vm/serializers.py +++ b/uncloud/uncloud_vm/serializers.py @@ -12,9 +12,9 @@ class VMHostSerializer(serializers.HyperlinkedModelSerializer): class VMProductSerializer(serializers.HyperlinkedModelSerializer): class Meta: model = VMProduct - fields = ['uuid', 'description', 'order', 'owner', 'status', 'name', \ + fields = ['uuid', 'order', 'owner', 'status', 'name', \ 'cores', 'ram_in_gb'] - read_only_fields = ['uuid', 'description', 'order', 'owner', 'status'] + read_only_fields = ['uuid', 'order', 'owner', 'status'] class VMSnapshotProductSerializer(serializers.ModelSerializer): class Meta: diff --git a/uncloud/ungleich_service/models.py b/uncloud/ungleich_service/models.py index ac1f90e..0e84f62 100644 --- a/uncloud/ungleich_service/models.py +++ b/uncloud/ungleich_service/models.py @@ -9,12 +9,18 @@ class MatrixServiceProduct(Product): setup_fee = 30 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 monthly_managment_fee + vm.recurring_price(RecurringPeriod.PER_MONTH) else: raise Exception('Invalid recurring period for VM Product pricing.') + + def setup_fee(self): + return setup_fee diff --git a/uncloud/ungleich_service/serializers.py b/uncloud/ungleich_service/serializers.py index 54737e9..ffd206f 100644 --- a/uncloud/ungleich_service/serializers.py +++ b/uncloud/ungleich_service/serializers.py @@ -1,7 +1,11 @@ from rest_framework import serializers from .models import MatrixServiceProduct +from uncloud_vm.serializers import VMProductSerializer class MatrixServiceProductSerializer(serializers.ModelSerializer): + vm = VMProductSerializer() + class Meta: model = MatrixServiceProduct - fields = '__all__' + fields = ['uuid', 'order', 'owner', 'status', 'vm', 'domain'] + read_only_fields = ['uuid', 'order', 'owner', 'status']