Commit 3057fc89 authored by haowang's avatar haowang

add tools virtual_vote api

parent 13f36757
import time
from utils.base import APIView
from gm_upload import upload, upload_file
from openpyxl import load_workbook
class VirtualVote(APIView):
def post(self, request):
xls_file = request.FILES.get('file')
if not xls_file:
return u'文件上传出错'
wb = load_workbook(xls_file)
data = wb.get_sheet_by_name(wb.get_sheet_names()[0])
row_data = [item.value for row in data.rows for item in row if item.value]
user_ids = []
for item in row_data:
try:
user_id = int(item)
user_ids.append(user_id)
except:
continue
if not user_ids:
return u'上传文件失败'
self.rpc['venus/sun/tools/virtual_vote'](user_ids=user_ids).unwrap()
return u'Ok'
...@@ -21,6 +21,8 @@ from .advertise import * ...@@ -21,6 +21,8 @@ from .advertise import *
from .channel_build import * from .channel_build import *
from .commons import * from .commons import *
from .pictorial import * from .pictorial import *
from .tools import *
urlpatterns = [ urlpatterns = [
# 登陆,注销相关 # 登陆,注销相关
...@@ -130,6 +132,9 @@ urlpatterns = [ ...@@ -130,6 +132,9 @@ urlpatterns = [
url(r'^pictorial/create$', PictorialUpdateOrCreate.as_view()), url(r'^pictorial/create$', PictorialUpdateOrCreate.as_view()),
url(r'^pictorial/topics$', PictorialTopics.as_view()), url(r'^pictorial/topics$', PictorialTopics.as_view()),
url(r'^pictorial/user/list$', PictorialUserList.as_view()), url(r'^pictorial/user/list$', PictorialUserList.as_view()),
# 工具
url(r'^tools/virtual_vote$', VirtualVote.as_view()),
] ]
search_urlpatterns = [ search_urlpatterns = [
......
...@@ -18,4 +18,5 @@ Pillow==5.4.1 ...@@ -18,4 +18,5 @@ Pillow==5.4.1
celery==4.2.1 celery==4.2.1
kombu==4.2.2.post1 kombu==4.2.2.post1
requests==2.21.0 requests==2.21.0
redis==2.10.6 redis==2.10.6
\ No newline at end of file openpyxl==2.6.2
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