Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
sun
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
alpha
sun
Commits
3057fc89
Commit
3057fc89
authored
Apr 11, 2019
by
haowang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add tools virtual_vote api
parent
13f36757
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
2 deletions
+38
-2
tools.py
api/tools.py
+31
-0
urls.py
api/urls.py
+5
-0
requirements.txt
requirements.txt
+2
-2
No files found.
api/tools.py
0 → 100644
View file @
3057fc89
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'
api/urls.py
View file @
3057fc89
...
...
@@ -21,6 +21,8 @@ from .advertise import *
from
.channel_build
import
*
from
.commons
import
*
from
.pictorial
import
*
from
.tools
import
*
urlpatterns
=
[
# 登陆,注销相关
...
...
@@ -130,6 +132,9 @@ urlpatterns = [
url
(
r'^pictorial/create$'
,
PictorialUpdateOrCreate
.
as_view
()),
url
(
r'^pictorial/topics$'
,
PictorialTopics
.
as_view
()),
url
(
r'^pictorial/user/list$'
,
PictorialUserList
.
as_view
()),
# 工具
url
(
r'^tools/virtual_vote$'
,
VirtualVote
.
as_view
()),
]
search_urlpatterns
=
[
...
...
requirements.txt
View file @
3057fc89
...
...
@@ -18,4 +18,5 @@ Pillow==5.4.1
celery
==4.2.1
kombu
==4.2.2.post1
requests
==2.21.0
redis
==2.10.6
\ No newline at end of file
redis
==2.10.6
openpyxl
==2.6.2
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment