Commit f02074d7 authored by haowang's avatar haowang

pull master

parents 6ca59e6f 99e8d186
......@@ -35,3 +35,39 @@ class VirtualVote(APIView):
self.rpc['venus/sun/tools/virtual_vote'](user_ids=user_ids).unwrap()
return {'message': u'上传成功', 'code': 200}
class BatchUpdateTopicTag(APIView):
def post(self, request):
xls_file = request.FILES.get('file')
if not xls_file:
return {'message': u'上传失败,请重新上传', 'code': 500}
wb = load_workbook(xls_file)
data = wb.get_sheet_by_name(wb.get_sheet_names()[0])
rows_data = [item.value for row in data.rows for item in row if item.value]
topic_infos = []
topic_tag_info = {}
for index, item in enumerate(rows_data):
if index == len(rows_data) - 1:
topic_infos.append(topic_tag_info)
if item.startswith('http:'):
if topic_tag_info.get('url'):
topic_infos.append(topic_tag_info)
topic_tag_info = {}
topic_tag_info['url'] = item.split('-')[0].replace('http://alpha.iyanzhi.com/', '')
continue
if item.split(':')[-1] and topic_tag_info.get('url'):
if not topic_tag_info.get('tags'):
topic_tag_info['tags'] = [item.split(':')[-1]]
else:
topic_tag_info['tags'].append(item.split(':')[-1])
self.rpc['venus/sun/tools/batch_update_topic_tags'](topic_infos=topic_infos).unwrap()
return {'message': u'上传成功', 'code': 200}
......@@ -134,15 +134,17 @@ urlpatterns = [
url(r'^pictorial/topics$', PictorialTopics.as_view()),
url(r'^pictorial/user/list$', PictorialUserList.as_view()),
# 工具
url(r'^tools/virtual_vote$', VirtualVote.as_view()),
#运营位
url(r'^topic/home_recommend/list', TopicHomeRecommendList.as_view()),
url(r'^topic/home_recommend/edit', TopicHomeRecommendEdit.as_view()),
url(r'^operation/home_fix', TopicHomeFixOperation.as_view()),
url(r'^operation/pictorial/recommend/list', PictorialHomeRecommendList.as_view()),
url(r'^operation/pictorial/recommend/update', PictorialHomeRecommendUpdate.as_view()),
# 工具
url(r'^tools/virtual_vote$', VirtualVote.as_view()),
url(r'^tools/batch_update_topic_tag$', BatchUpdateTopicTag.as_view()),
]
search_urlpatterns = [
......
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