Commit 399e502e authored by 王浩's avatar 王浩

Merge branch 'haow/dev' into 'dev'

fix code

See merge request alpha/sun!253
parents a5046db2 7984f3af
......@@ -55,10 +55,16 @@ class BrandInfoView(APIView):
data = self.rpc['neptune/commodity/brand/info'](id_=id_).unwrap()
classify_infos = self.rpc['neptune/commodity/classify/infos'](brand_id=id_).unwrap()
data['classify_infos'] = [{'id': obj.get('id'), 'cn_name': obj.get('cn_name')} for obj in classify_infos]
if classify_infos:
data['classify_infos'] = [{'id': obj.get('id'), 'cn_name': obj.get('cn_name')} for obj in classify_infos]
else:
data['classify_infos'] = []
category_ids = self.rpc['neptune/commodity/brand/category_ids'](id_=id_).unwrap()
category_infos = self.rpc['neptune/commodity/category/infos'](ids=category_ids).unwrap()
data['category_infos'] = [{'id': obj.get('id'), 'cn_name': obj.get('cn_name')} for obj in category_infos]
if category_infos:
data['category_infos'] = [{'id': obj.get('id'), 'cn_name': obj.get('cn_name')} for obj in category_infos]
else:
data['category_infos'] = []
return data
......
......@@ -19,7 +19,7 @@ class ProductListView(APIView):
for obj in category_infos:
product_id = obj.get('product_id')
if ret.get(str(product_id)):
ret[str(product_id)] = ret.get(str(product_id)).append(obj)
ret.get(str(product_id)).append(obj)
else:
ret[str(product_id)] = [obj]
return ret
......@@ -32,7 +32,7 @@ class ProductListView(APIView):
for obj in effect_infos:
product_id = obj.get('product_id')
if ret.get(str(product_id)):
ret[str(product_id)] = ret.get(str(product_id)).append(obj)
ret.get(str(product_id)).append(obj)
else:
ret[str(product_id)] = [obj]
return ret
......@@ -45,7 +45,7 @@ class ProductListView(APIView):
for obj in classify_infos:
product_id = obj.get('product_id')
if ret.get(str(product_id)):
ret[str(product_id)] = ret.get(str(product_id)).append(obj)
ret.get(str(product_id)).append(obj)
else:
ret[str(product_id)] = [obj]
return ret
......@@ -61,6 +61,7 @@ class ProductListView(APIView):
has_brand = request.GET.get('has_brand', None)
has_image = request.GET.get('has_image', None)
brand_id = request.GET.get('brand_id', None)
classify_id = request.GET.get('classify_id', None)
category_id = request.GET.get('category_id', None)
price_low = request.GET.get('price_low', None)
price_high = request.GET.get('price_high', None)
......@@ -70,16 +71,16 @@ class ProductListView(APIView):
comment_nums_high = request.GET.get('comment_nums_high', None)
data = self.rpc['neptune/commodity/product/list'](
offset=offset, count=count, id_=id_, cn_name=cn_name, en_name=en_name, alias=alias, is_online=is_online, has_area=has_area,
has_brand=has_brand, has_image=has_image, brand_id=brand_id, category_id=category_id, price_low=price_low, price_high=price_high,
grade_low=grade_low, grade_high=grade_high, comment_nums_low=comment_nums_low, comment_nums_high=comment_nums_high).unwrap()
offset=offset, count=count, id_=id_, cn_name=cn_name, en_name=en_name, alias=alias, is_online=is_online,
has_area=has_area, has_brand=has_brand, has_image=has_image, brand_id=brand_id, classify_id=classify_id,
category_id=category_id, price_low=price_low, price_high=price_high, grade_low=grade_low, grade_high=grade_high,
comment_nums_low=comment_nums_low, comment_nums_high=comment_nums_high).unwrap()
product_ids = [obj.get('id') for obj in data]
brand_product_dict = self.get_brand_infos(product_ids)
category_product_dict = self.get_category_infos(product_ids)
effect_product_dict = self.get_effect_infos(product_ids)
classify_product_dict = self.get_classify_infos(product_ids)
print(category_product_dict, effect_product_dict, classify_product_dict)
for obj in data:
product_id = obj.get('id')
......@@ -99,7 +100,7 @@ class ProductListView(APIView):
count = self.rpc['neptune/commodity/product/count'](
id_=id_, cn_name=cn_name, en_name=en_name, alias=alias, is_online=is_online, has_area=has_area, has_brand=has_brand,
has_image=has_image, brand_id=brand_id, category_id=category_id, price_low=price_low, price_high=price_high,
has_image=has_image, brand_id=brand_id, category_id=category_id, classify_id=classify_id, price_low=price_low, price_high=price_high,
grade_low=grade_low, grade_high=grade_high, comment_nums_low=comment_nums_low, comment_nums_high=comment_nums_high).unwrap()
result = {
'list': data,
......
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