forked from uncloud/uncloud
Make recurring_period an Enum, VMProduct a Product, initial wire for
order
This commit is contained in:
parent
1dd3324275
commit
b2fe5014d8
6 changed files with 113 additions and 24 deletions
|
|
@ -3,6 +3,7 @@ from rest_framework import serializers
|
|||
from .models import *
|
||||
|
||||
from functools import reduce
|
||||
from uncloud_vm.serializers import VMProductSerializer
|
||||
|
||||
class BillSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
|
|
@ -20,11 +21,30 @@ class PaymentMethodSerializer(serializers.ModelSerializer):
|
|||
model = PaymentMethod
|
||||
fields = ['owner', 'primary', 'source', 'description']
|
||||
|
||||
class ProductSerializer(serializers.Serializer):
|
||||
vms = VMProductSerializer(many=True, required=False)
|
||||
class meta:
|
||||
fields = ['vms']
|
||||
|
||||
def create(self, validated_data):
|
||||
pass
|
||||
|
||||
class OrderSerializer(serializers.ModelSerializer):
|
||||
products = ProductSerializer(many=True)
|
||||
class Meta:
|
||||
model = Order
|
||||
fields = '__all__'
|
||||
|
||||
def create(self, validated_data):
|
||||
products_data = validated_data.pop('products')
|
||||
order = Order.objects.create(**validated_data)
|
||||
for product_data in products_data:
|
||||
print("spouik")
|
||||
print(product_data)
|
||||
pass # TODO
|
||||
|
||||
return order
|
||||
|
||||
class UserSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = get_user_model()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue