change offer list and add party model and serializer
This commit is contained in:
@@ -94,4 +94,30 @@ class OffersSerializer(serializers.ModelSerializer):
|
||||
model = Offer
|
||||
fields = [
|
||||
'id', 'number', 'price', 'price_type', 'phone', 'comment', 'qqs',
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
|
||||
class OrderListForOfferSerializer(serializers.ModelSerializer):
|
||||
offers = OffersSerializer(many=True)
|
||||
product = serializers.SerializerMethodField(method_name='get_product')
|
||||
unity = serializers.SerializerMethodField(method_name='get_unity')
|
||||
|
||||
class Meta:
|
||||
model = Order
|
||||
fields = [
|
||||
'id', 'product', 'unity', 'quantity', 'date', 'offers'
|
||||
]
|
||||
|
||||
def get_product(self, obj):
|
||||
return {
|
||||
'id': obj.product.id,
|
||||
'name': obj.product.name,
|
||||
'type': obj.product.type,
|
||||
}
|
||||
|
||||
def get_unity(self, obj):
|
||||
return {
|
||||
'id': obj.unity.id,
|
||||
'value': obj.unity.value
|
||||
}
|
||||
Reference in New Issue
Block a user