forked from uncloud/uncloud
28 lines
1.2 KiB
Python
28 lines
1.2 KiB
Python
from rest_framework import serializers
|
|
from .models import *
|
|
from uncloud_vm.serializers import ManagedVMProductSerializer
|
|
from uncloud_vm.models import VMProduct
|
|
from uncloud_pay.models import RecurringPeriod
|
|
|
|
class MatrixServiceProductSerializer(serializers.ModelSerializer):
|
|
vm = ManagedVMProductSerializer()
|
|
|
|
# Custom field used at creation (= ordering) only.
|
|
recurring_period = serializers.ChoiceField(
|
|
choices=MatrixServiceProduct.allowed_recurring_periods())
|
|
|
|
class Meta:
|
|
model = MatrixServiceProduct
|
|
fields = ['uuid', 'order', 'owner', 'status', 'vm', 'domain', 'recurring_period']
|
|
read_only_fields = ['uuid', 'order', 'owner', 'status']
|
|
|
|
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']
|