Commit c04745b0 authored by 王浩's avatar 王浩

Merge branch 'haow/dev' into 'dev'

fix code

See merge request alpha/sun!231
parents 0fc74bd7 bb807b66
...@@ -30,7 +30,7 @@ class BrandListView(APIView): ...@@ -30,7 +30,7 @@ class BrandListView(APIView):
for obj in data: for obj in data:
brand_id = obj.get('id') brand_id = obj.get('id')
obj['product_num'] = product_count.get(str(brand_id)) or 0 obj['product_num'] = product_count.get(str(brand_id)) or 0
obj['category_names'] = [category_dict.get(str(id_)).get('cn_name') obj['category_names'] = [{'id': id_, 'cn_name': category_dict.get(str(id_)).get('cn_name')}
for id_ in category_ids.get(str(brand_id))] if category_dict.get(str(id_)) else [] for id_ in category_ids.get(str(brand_id))] if category_dict.get(str(id_)) else []
obj.pop('platform') obj.pop('platform')
......
...@@ -83,11 +83,11 @@ class ProductListView(APIView): ...@@ -83,11 +83,11 @@ class ProductListView(APIView):
for obj in data: for obj in data:
product_id = obj.get('id') product_id = obj.get('id')
obj['brand_name'] = brand_product_dict.get(str(product_id)).get('cn_name') if brand_product_dict.get(str(product_id)) else '' obj['brand_name'] = brand_product_dict.get(str(product_id)).get('cn_name') if brand_product_dict.get(str(product_id)) else ''
obj['category_names'] = [obj.get('cn_name') obj['category_names'] = [{'id': obj.get('id'), 'cn_name': obj.get('cn_name')}
for obj in category_product_dict.get(str(product_id))] if category_product_dict.get(str(product_id)) else [] for obj in category_product_dict.get(str(product_id))] if category_product_dict.get(str(product_id)) else []
obj['effect_names'] = [obj.get('cn_name') obj['effect_names'] = [{'id': obj.get('id'), 'cn_name': obj.get('cn_name')}
for obj in effect_product_dict.get(str(product_id))] if effect_product_dict.get(str(product_id)) else [] for obj in effect_product_dict.get(str(product_id))] if effect_product_dict.get(str(product_id)) else []
obj['classify_names'] = [obj.get('cn_name') obj['classify_names'] = [{'id': obj.get('id'), 'cn_name': obj.get('cn_name')}
for obj in classify_product_dict.get(str(product_id))] if classify_product_dict.get(str(product_id)) else [] for obj in classify_product_dict.get(str(product_id))] if classify_product_dict.get(str(product_id)) else []
obj.pop('norms') obj.pop('norms')
...@@ -111,13 +111,13 @@ class ProductInfoView(APIView): ...@@ -111,13 +111,13 @@ class ProductInfoView(APIView):
category_infos = self.rpc['neptune/commodity/category/infos'](product_id=product_id).unwrap() category_infos = self.rpc['neptune/commodity/category/infos'](product_id=product_id).unwrap()
if not category_infos: if not category_infos:
return [] return []
return [obj.get('cn_name') for obj in category_infos] return [{'id': obj.get('id'), 'cn_name': obj.get('cn_name')} for obj in category_infos]
def get_effect_names(self, product_id): def get_effect_names(self, product_id):
effect_infos = self.rpc['neptune/commodity/effect/infos'](product_id=product_id).unwrap() effect_infos = self.rpc['neptune/commodity/effect/infos'](product_id=product_id).unwrap()
if not effect_infos: if not effect_infos:
return [] return []
return [obj.get('cn_name') for obj in effect_infos] return [{'id': obj.get('id'), 'cn_name': obj.get('cn_name')} for obj in effect_infos]
def get(self, request): def get(self, request):
id_ = request.GET.get('id') id_ = request.GET.get('id')
...@@ -130,7 +130,7 @@ class ProductInfoView(APIView): ...@@ -130,7 +130,7 @@ class ProductInfoView(APIView):
brand_info = self.rpc['neptune/commodity/brand/infos'](product_id=id_).unwrap() brand_info = self.rpc['neptune/commodity/brand/infos'](product_id=id_).unwrap()
data['brand_name'] = brand_info[0].get('cn_name') if brand_info else '' data['brand_name'] = brand_info[0].get('cn_name') if brand_info else ''
classify_infos = self.rpc['neptune/commodity/classify/infos'](product_ids=[id_]).unwrap() classify_infos = self.rpc['neptune/commodity/classify/infos'](product_ids=[id_]).unwrap()
data['classify_names'] = [obj.get('cn_name') for obj in classify_infos] data['classify_names'] = [{'id': obj.get('id'), 'cn_name': obj.get('cn_name')} for obj in classify_infos]
data['category_names'] = self.get_category_names(id_) data['category_names'] = self.get_category_names(id_)
data['effect_names'] = self.get_effect_names(id_) data['effect_names'] = self.get_effect_names(id_)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment