2017-02-03 10:04:57 +00:00
|
|
|
from rest_framework import serializers
|
|
|
|
|
|
|
|
from longclaw.products.serializers import ProductVariantSerializer
|
|
|
|
from longclaw.basket.models import BasketItem
|
|
|
|
|
|
|
|
class BasketItemSerializer(serializers.ModelSerializer):
|
|
|
|
|
2017-02-03 17:24:41 +00:00
|
|
|
variant = ProductVariantSerializer()
|
2017-02-03 10:04:57 +00:00
|
|
|
price = serializers.SerializerMethodField()
|
|
|
|
total = serializers.SerializerMethodField()
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = BasketItem
|
|
|
|
fields = "__all__"
|
|
|
|
|
|
|
|
def get_price(self, obj):
|
|
|
|
return obj.price()
|
|
|
|
|
|
|
|
def get_total(self, obj):
|
|
|
|
return obj.total()
|
|
|
|
|