base of product-quota & list cities by province
This commit is contained in:
@@ -3,6 +3,12 @@ from apps.product import models as product_models
|
||||
from apps.authorization.api.v1 import serializers as authorize_serializers
|
||||
|
||||
|
||||
class ProductCategorySerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = product_models.ProductCategory
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class ProductSerializer(serializers.ModelSerializer):
|
||||
""" Serializer of product """
|
||||
|
||||
@@ -14,6 +20,11 @@ class ProductSerializer(serializers.ModelSerializer):
|
||||
""" Custom output of product serializer """
|
||||
|
||||
representation = super().to_representation(instance)
|
||||
if instance.category:
|
||||
representation['category'] = {
|
||||
'id': instance.category.id,
|
||||
'name': instance.category.name
|
||||
}
|
||||
|
||||
return representation
|
||||
|
||||
@@ -27,6 +38,11 @@ class AttributeSerializer(serializers.ModelSerializer):
|
||||
|
||||
def to_representation(self, instance):
|
||||
representation = super().to_representation(instance)
|
||||
if instance.product:
|
||||
representation['product'] = {
|
||||
'id': instance.product.id,
|
||||
'name': instance.product.name
|
||||
}
|
||||
return representation
|
||||
|
||||
|
||||
@@ -75,13 +91,18 @@ class SaleUnitSerializer(serializers.ModelSerializer):
|
||||
|
||||
def to_representation(self, instance):
|
||||
representation = super().to_representation(instance)
|
||||
if instance.product:
|
||||
representation['product'] = {
|
||||
'id': instance.product.id,
|
||||
'name': instance.product.name
|
||||
}
|
||||
return representation
|
||||
|
||||
|
||||
class IncentivePlanSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = product_models.IncentivePlan
|
||||
fields = '__all_'
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class QuotaSerializer(serializers.ModelSerializer):
|
||||
|
||||
Reference in New Issue
Block a user