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
0
Merge Requests
0
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
谢林臻
sun
Commits
9f0d4c07
Commit
9f0d4c07
authored
Apr 18, 2019
by
杨成林
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'ycl/master_to_dev' into 'dev'
Ycl/master to dev See merge request
alpha/sun!178
parents
a3ae7dc5
c092e4ed
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
90 additions
and
8 deletions
+90
-8
pictorial.py
api/pictorial.py
+3
-1
tag.py
api/tag.py
+5
-5
tools.py
api/tools.py
+73
-0
topic.py
api/topic.py
+1
-1
urls.py
api/urls.py
+7
-1
requirements.txt
requirements.txt
+1
-0
No files found.
api/pictorial.py
View file @
9f0d4c07
...
@@ -59,7 +59,9 @@ class PictorialUpdateOrCreate(APIView):
...
@@ -59,7 +59,9 @@ class PictorialUpdateOrCreate(APIView):
'pictorial_user_ids'
:
pictorial_user_ids
,
'pictorial_user_ids'
:
pictorial_user_ids
,
'icon'
:
request
.
POST
.
get
(
'icon'
,
''
),
'icon'
:
request
.
POST
.
get
(
'icon'
,
''
),
'collection_tag_ids'
:
collection_tag_ids
,
'collection_tag_ids'
:
collection_tag_ids
,
'is_home_recommend'
:
request
.
POST
.
get
(
'is_home_recommend'
,
0
),
'is_home_recommend'
:
int
(
request
.
POST
.
get
(
'is_home_recommend'
,
0
)),
'add_score'
:
int
(
request
.
POST
.
get
(
'add_score'
,
0
)),
}
}
try
:
try
:
data
=
self
.
rpc
[
'venus/sun/pictorial/edit'
](
id
=
id
,
data
=
data
)
.
unwrap
()
data
=
self
.
rpc
[
'venus/sun/pictorial/edit'
](
id
=
id
,
data
=
data
)
.
unwrap
()
...
...
api/tag.py
View file @
9f0d4c07
...
@@ -54,15 +54,15 @@ class TagUpdateOrCreateView(APIView):
...
@@ -54,15 +54,15 @@ class TagUpdateOrCreateView(APIView):
tagtypes
=
list
(
set
(
map
(
lambda
x
:
x
.
split
(
":"
)[
0
],
json
.
loads
((
request
.
POST
.
get
(
'tagtypes'
,
'[]'
))))))
tagtypes
=
list
(
set
(
map
(
lambda
x
:
x
.
split
(
":"
)[
0
],
json
.
loads
((
request
.
POST
.
get
(
'tagtypes'
,
'[]'
))))))
data
=
{
data
=
{
'name'
:
request
.
POST
.
get
(
'name'
)
.
lower
(),
'name'
:
request
.
POST
.
get
(
'name'
)
.
lower
(),
'description'
:
request
.
POST
.
get
(
'description'
),
'description'
:
request
.
POST
.
get
(
'description'
,
''
),
'down_tags'
:
down_tags
,
'down_tags'
:
down_tags
,
'up_tags'
:
up_tags
,
'up_tags'
:
up_tags
,
'tagtypes'
:
tagtypes
,
'tagtypes'
:
tagtypes
,
'icon_url'
:
request
.
POST
.
get
(
'icon_url'
,
''
)[:
-
2
],
'icon_url'
:
request
.
POST
.
get
(
'icon_url'
,
''
)[:
-
2
],
'platform'
:
request
.
POST
.
get
(
'platform'
),
'platform'
:
request
.
POST
.
get
(
'platform'
,
1
),
'collection'
:
request
.
POST
.
get
(
'collection'
),
'collection'
:
request
.
POST
.
get
(
'collection'
,
0
),
'alias'
:
request
.
POST
.
get
(
'alias'
),
'alias'
:
request
.
POST
.
get
(
'alias'
,
''
),
'is_show_in_register'
:
request
.
POST
.
get
(
'is_show_in_register'
)
'is_show_in_register'
:
request
.
POST
.
get
(
'is_show_in_register'
,
'false'
)
}
}
try
:
try
:
data
=
self
.
rpc
[
'venus/sun/tag/edit'
](
id
=
id
,
data
=
data
)
.
unwrap
()
data
=
self
.
rpc
[
'venus/sun/tag/edit'
](
id
=
id
,
data
=
data
)
.
unwrap
()
...
...
api/tools.py
0 → 100644
View file @
9f0d4c07
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
{
'message'
:
u'上传失败,请重新上传'
,
'code'
:
500
}
wb
=
load_workbook
(
xls_file
)
data
=
wb
.
get_sheet_by_name
(
wb
.
get_sheet_names
()[
0
])
columns
=
[
item
for
item
in
data
.
columns
]
column_data
=
columns
[
0
]
column_data
=
[
item
.
value
for
item
in
column_data
]
if
'用户id'
not
in
column_data
:
return
{
'message'
:
u'文件数据格式错误,请确保内容中有”用户id“标题'
,
'code'
:
500
}
user_ids
=
[]
for
item
in
column_data
:
try
:
user_id
=
int
(
item
)
user_ids
.
append
(
user_id
)
except
:
continue
if
not
user_ids
:
return
{
'message'
:
u'上传失败,文件第一列不存在user_id数据'
,
'code'
:
500
}
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
}
api/topic.py
View file @
9f0d4c07
...
@@ -26,7 +26,7 @@ class TopicListView(APIView):
...
@@ -26,7 +26,7 @@ class TopicListView(APIView):
if
int
(
drop_score
)
==
0
:
if
int
(
drop_score
)
==
0
:
filters
.
update
({
'drop_score'
:
int
(
drop_score
)})
filters
.
update
({
'drop_score'
:
int
(
drop_score
)})
elif
int
(
drop_score
)
==
1
:
elif
int
(
drop_score
)
==
1
:
filters
.
update
({
'drop_score__
gt
'
:
int
(
drop_score
)})
filters
.
update
({
'drop_score__
exclude
'
:
int
(
drop_score
)})
res
=
self
.
rpc
[
'physical/search/business/topic'
](
res
=
self
.
rpc
[
'physical/search/business/topic'
](
offset
=
(
page
-
1
)
*
limit
,
offset
=
(
page
-
1
)
*
limit
,
...
...
api/urls.py
View file @
9f0d4c07
...
@@ -22,6 +22,8 @@ from .channel_build import *
...
@@ -22,6 +22,8 @@ from .channel_build import *
from
.commons
import
*
from
.commons
import
*
from
.pictorial
import
*
from
.pictorial
import
*
from
.operation
import
*
from
.operation
import
*
from
.tools
import
*
urlpatterns
=
[
urlpatterns
=
[
# 登陆,注销相关
# 登陆,注销相关
...
@@ -133,12 +135,16 @@ urlpatterns = [
...
@@ -133,12 +135,16 @@ urlpatterns = [
url
(
r'^pictorial/user/list$'
,
PictorialUserList
.
as_view
()),
url
(
r'^pictorial/user/list$'
,
PictorialUserList
.
as_view
()),
#运营位
#运营位
url
(
r'^topic/home_recommend/list'
,
TopicHomeRecommendList
.
as_view
()),
url
(
r'^topic/home_recommend/list'
,
TopicHomeRecommendList
.
as_view
()),
url
(
r'^topic/home_recommend/edit'
,
TopicHomeRecommendEdit
.
as_view
()),
url
(
r'^topic/home_recommend/edit'
,
TopicHomeRecommendEdit
.
as_view
()),
url
(
r'^operation/home_fix'
,
TopicHomeFixOperation
.
as_view
()),
url
(
r'^operation/home_fix'
,
TopicHomeFixOperation
.
as_view
()),
url
(
r'^operation/pictorial/recommend/list'
,
PictorialHomeRecommendList
.
as_view
()),
url
(
r'^operation/pictorial/recommend/list'
,
PictorialHomeRecommendList
.
as_view
()),
url
(
r'^operation/pictorial/recommend/update'
,
PictorialHomeRecommendUpdate
.
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
=
[
search_urlpatterns
=
[
...
...
requirements.txt
View file @
9f0d4c07
...
@@ -19,3 +19,4 @@ celery==4.2.1
...
@@ -19,3 +19,4 @@ 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
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