2020-02-28 13:46:33 +00:00
|
|
|
from rest_framework import serializers
|
2020-04-17 08:08:33 +00:00
|
|
|
from .models import *
|
2020-03-03 09:51:16 +00:00
|
|
|
from uncloud_vm.serializers import ManagedVMProductSerializer
|
2020-02-29 08:08:30 +00:00
|
|
|
from uncloud_vm.models import VMProduct
|
2020-03-03 09:51:16 +00:00
|
|
|
from uncloud_pay.models import RecurringPeriod
|
2020-02-28 13:46:33 +00:00
|
|
|
|
|
|
|
class MatrixServiceProductSerializer(serializers.ModelSerializer):
|
2020-03-03 09:51:16 +00:00
|
|
|
vm = ManagedVMProductSerializer()
|
|
|
|
|
|
|
|
# Custom field used at creation (= ordering) only.
|
|
|
|
recurring_period = serializers.ChoiceField(
|
|
|
|
choices=MatrixServiceProduct.allowed_recurring_periods())
|
2020-02-28 15:26:45 +00:00
|
|
|
|
2020-02-28 13:46:33 +00:00
|
|
|
class Meta:
|
|
|
|
model = MatrixServiceProduct
|
2020-03-03 09:51:16 +00:00
|
|
|
fields = ['uuid', 'order', 'owner', 'status', 'vm', 'domain', 'recurring_period']
|
2020-02-28 15:26:45 +00:00
|
|
|
read_only_fields = ['uuid', 'order', 'owner', 'status']
|
2020-04-17 08:08:33 +00:00
|
|
|
|
|
|
|
class GenericServiceProductSerializer(serializers.ModelSerializer):
|
|
|
|
# Custom field used at creation (= ordering) only.
|
|
|
|
recurring_period = serializers.ChoiceField(
|
|
|
|
choices=GenericServiceProduct.allowed_recurring_periods())
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = GenericServiceProduct
|
|
|
|
fields = ['uuid', 'order', 'owner', 'status', 'custom_recurring_price',
|
|
|
|
'custom_description', 'custom_one_time_price', 'recurring_period']
|
|
|
|
read_only_fields = ['uuid', 'order', 'owner', 'status']
|