Commit f73b4b0f authored by 杨成林's avatar 杨成林

Merge branch 'ycl/fix_dev' into 'dev'

Ycl/fix dev

See merge request alpha/sun!278
parents 99ecf7f9 d1646d6b
......@@ -124,7 +124,7 @@ class PictorialActivityView(APIView):
return data
class PictorialActivityOlineView(APIView):
class PictorialActivityOnlineView(APIView):
def post(self, request):
......
......@@ -26,15 +26,16 @@ class BrandListView(APIView):
category_infos = self.rpc['neptune/commodity/category/infos'](brand_ids=brand_ids).unwrap()
category_dict = {}
for obj in category_infos:
obj_id = obj.get('brand_id')
if category_dict.get(str(obj_id)):
category_dict.get(str(obj_id)).append(obj)
else:
category_dict[str(obj_id)] = [obj]
if category_infos:
for obj in category_infos:
obj_id = obj.get('brand_id')
if category_dict.get(str(obj_id)):
category_dict.get(str(obj_id)).append(obj)
else:
category_dict[str(obj_id)] = [obj]
classify_infos = self.rpc['neptune/commodity/classify/infos'](brand_ids=brand_ids).unwrap()
classify_dict = {str(obj.get('brand_id')): obj for obj in classify_infos}
classify_dict = {str(obj.get('brand_id')): obj for obj in classify_infos} if classify_infos else {}
for obj in data:
brand_id = obj.get('id')
......
......@@ -10,13 +10,12 @@ class PictorialListView(APIView):
offset = int(request.GET.get('page', 1))
limit = int(request.GET.get('limit', 10))
filters = self.handle_filter(request.GET.get('filter', '{}'))
product_id = request.GET.get('product_id')
if star_id:
filters.update({'star_id': star_id})
if user_id:
filters.update({'user_id': user_id})
try:
data = self.rpc['venus/sun/pictorial/list'](filters=filters, offset=(offset-1)*limit, limit=limit, product_id=product_id).unwrap()
data = self.rpc['venus/sun/pictorial/list'](filters=filters, offset=(offset-1)*limit, limit=limit).unwrap()
except Exception as e:
error_logger.error(u'获取画报列表失败%s' , e)
raise
......@@ -47,7 +46,7 @@ class PictorialUpdateOrCreate(APIView):
def post(self, request):
id = request.POST.get('id')
id = int(request.POST.get('id')) if request.POST.get('id') else None
star_ids = json.loads(request.POST.get('star', '[]'))
pictorial_user_ids = json.loads(request.POST.get('pictorial_user_ids', '[]'))
collection_tag_ids = json.loads(request.POST.get('collection_tag_ids', '[]'))
......@@ -66,7 +65,8 @@ class PictorialUpdateOrCreate(APIView):
'add_score': int(request.POST.get('add_score', 0)),
'is_public': True if request.POST.get('is_public') == "true" else False,
'is_feed': int(request.POST.get('is_feed', 0)),
'pictorial_activity_ids': [int(pictorial_activity_id) if pictorial_activity_id else None]
'pictorial_activity_ids': [int(pictorial_activity_id)] if pictorial_activity_id else [],
'alias': request.POST.get('alias', ''),
}
try:
......@@ -147,37 +147,3 @@ class PictorialFeedDelete(APIView):
return {
'message': '删除成功'
}
class PictorialProductAdd(APIView):
"""画报添加商品关系"""
def post(self, request):
id_ = request.POST.get('id')
product_id = request.POST.get('product_id')
try:
self.rpc['venus/sun/pictorial/add_product'](id_=id_, product_id=product_id).unwrap()
except Exception as e:
error_logger.error(u'编辑%s画报信息失败%s' % (id_, e))
raise
return {
'message': '更新成功'
}
class PictorialProductDel(APIView):
"""画报删除商品关系"""
def post(self, request):
id_ = request.POST.get('id')
product_id = request.POST.get('product_id')
try:
self.rpc['venus/sun/pictorial/del_product'](id_=id_, product_id=product_id).unwrap()
except Exception as e:
error_logger.error(u'编辑%s画报信息失败%s' % (id_, e))
raise
return {
'message': '更新成功'
}
......@@ -69,12 +69,15 @@ class ProductListView(APIView):
grade_high = request.GET.get('grade_high', None)
comment_nums_low = request.GET.get('comment_nums_low', None)
comment_nums_high = request.GET.get('comment_nums_high', None)
effect_name = request.GET.get('effect_name', None)
sorted_condition = request.GET.get('sorted_condition', 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, 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()
comment_nums_low=comment_nums_low, comment_nums_high=comment_nums_high, effect_name=effect_name,
sorted_condition=sorted_condition).unwrap()
product_ids = [obj.get('id') for obj in data]
brand_product_dict = self.get_brand_infos(product_ids)
......@@ -100,8 +103,9 @@ 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, 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()
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, effect_name=effect_name).unwrap()
result = {
'list': data,
'total': count,
......@@ -158,6 +162,7 @@ class ProductCreateView(APIView):
category_ids = json.loads(request.POST.get('category_ids', '[]'))
effect_ids = json.loads(request.POST.get('effect_ids', '[]'))
is_online = request.POST.get('is_online')
brand_id = request.POST.get('brand_id')
if not cn_name or not image:
return r'缺少参数'
......@@ -165,7 +170,7 @@ class ProductCreateView(APIView):
data = self.rpc['neptune/commodity/product/create'](
cn_name=cn_name, en_name=en_name, alias=alias, image=image, norms=norms, grade=grade, price=price,
country=country, description=description, comment_nums=comment_nums, classify_ids=classify_ids,
category_ids=category_ids, effect_ids=effect_ids, is_online=is_online).unwrap()
category_ids=category_ids, effect_ids=effect_ids, is_online=is_online, brand_id=brand_id).unwrap()
return data
......@@ -188,6 +193,7 @@ class ProductUpdateView(APIView):
category_ids = json.loads(request.POST.get('category_ids', '[]'))
effect_ids = json.loads(request.POST.get('effect_ids', '[]'))
is_online = request.POST.get('is_online')
brand_id = request.POST.get('brand_id')
if not id_:
return r'缺少参数'
......@@ -195,6 +201,6 @@ class ProductUpdateView(APIView):
data = self.rpc['neptune/commodity/product/update'](
id_=id_, cn_name=cn_name, en_name=en_name, alias=alias, image=image, norms=norms, grade=grade, price=price,
country=country, description=description, comment_nums=comment_nums, classify_ids=classify_ids,
category_ids=category_ids, effect_ids=effect_ids, is_online=is_online).unwrap()
category_ids=category_ids, effect_ids=effect_ids, is_online=is_online, brand_id=brand_id).unwrap()
return data
......@@ -97,11 +97,29 @@ class TagTypeSearchView(APIView):
class PictorialSearchView(APIView):
def get(self, request):
name = request.GET.get('name')
offset, count = get_offset_count(request)
try:
data = self.rpc['venus/sun/pictorial/search'](name=name).unwrap()
data = self.rpc['venus/sun/pictorial/search'](name=name, offset=offset, count=count).unwrap()
except Exception as e:
raise e
return {
'data': ['{id}:{name}'.format(id=search_data['id'], name=search_data['name']) for search_data in data]
}
class PictorialActivitySearchView(APIView):
def get(self, request):
name = request.GET.get('name')
offset, count = get_offset_count(request)
try:
data = self.rpc['venus/sun/activity/pictorial/search'](name=name, offset=offset, count=count).unwrap()
except Exception as e:
raise e
return {
'data': ['{id}:{name}'.format(id=search_data['id'], name=search_data['name']) for search_data in data]
}
\ No newline at end of file
......@@ -48,6 +48,7 @@ class TagUpdateOrCreateView(APIView):
return {'data': data}
def post(self, request):
id = request.POST.get('id')
down_tags = list(set(map(lambda x: x.split(":")[0], json.loads((request.POST.get('down_tags', '[]'))))))
up_tags = list(set(map(lambda x: x.split(":")[0], json.loads((request.POST.get('up_tags', '[]'))))))
......
......@@ -251,13 +251,13 @@ class TopicProductAdd(APIView):
"""帖子添加商品关系"""
def post(self, request):
id_ = request.POST.get('id')
ids = json.loads(request.POST.get('ids', '[]'))
product_id = request.POST.get('product_id')
try:
self.rpc['venus/sun/topic/add_product'](id_=id_, product_id=product_id).unwrap()
self.rpc['venus/sun/topic/add_product'](ids=ids, product_id=product_id).unwrap()
except Exception as e:
error_logger.error(u'编辑%s帖子信息失败%s' % (id_, e))
error_logger.error(u'编辑%s帖子信息失败%s' % (ids, e))
raise
return {
'message': '更新成功'
......@@ -268,13 +268,13 @@ class TopicProductDel(APIView):
"""帖子删除商品关系"""
def post(self, request):
id_ = request.POST.get('id')
ids = json.loads(request.POST.get('ids', '[]'))
product_id = request.POST.get('product_id')
try:
self.rpc['venus/sun/topic/del_product'](id_=id_, product_id=product_id).unwrap()
self.rpc['venus/sun/topic/del_product'](ids=ids, product_id=product_id).unwrap()
except Exception as e:
error_logger.error(u'编辑%s帖子信息失败%s' % (id_, e))
error_logger.error(u'编辑%s帖子信息失败%s' % (ids, e))
raise
return {
'message': '更新成功'
......
......@@ -152,8 +152,6 @@ urlpatterns = [
url(r'^pictorial/feed/list$', PictorialFeedlListView.as_view()),
url(r'^pictorial/feed/rank$', PictorialFeedlRank.as_view()),
url(r'^pictorial/feed/delete$', PictorialFeedDelete.as_view()),
url(r'^pictorial/product/add$', PictorialProductAdd.as_view()),
url(r'^pictorial/product/del$', PictorialProductDel.as_view()),
#运营位
url(r'^topic/home_recommend/list', TopicHomeRecommendList.as_view()),
......@@ -195,7 +193,7 @@ urlpatterns = [
url(r'^activity/pictorial$', PictorialActivityView.as_view()),
url(r'^activity/pictorial$', PictorialActivityView.as_view()),
url(r'^activity/pictorial/list$', PictorialActivityListView.as_view()),
url(r'^activity/pictorial/online$', PictorialActivityOlineView.as_view()),
url(r'^activity/pictorial/online$', PictorialActivityOnlineView.as_view()),
# 品牌
url(r'^brand/list$', BrandListView.as_view()),
......@@ -229,6 +227,7 @@ search_urlpatterns = [
url(r'search/topic$', TopicSearchView.as_view()),
url(r'search/tagtype$', TagTypeSearchView.as_view()),
url(r'search/pictorial$', PictorialSearchView.as_view()),
url(r'search/pictorial_activity$', PictorialActivitySearchView.as_view()),
]
common_urlpatterns = [
......
......@@ -69,7 +69,7 @@ class UserUpdateOrCreate(APIView):
data = {
'user_id': user_id,
'password': password,
'is_recommend': int(request.POST.get('is_recommend')),
'is_recommend': int(request.POST.get('is_recommend')) if request.POST.get('is_recommend') else 0,
'profile_pic': request.POST.get('avatar')[:-2],
'nick_name': request.POST.get('nick_name'),
'tag_ids': tag_ids,
......
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