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
db21648e
Commit
db21648e
authored
Apr 11, 2019
by
haowang
Browse files
Options
Browse Files
Download
Plain Diff
fix conflicts
parents
3057fc89
13e70c15
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
173 additions
and
12 deletions
+173
-12
__init__.py
api/mock/__init__.py
+0
-6
operation.py
api/operation.py
+121
-0
pictorial.py
api/pictorial.py
+2
-1
topic.py
api/topic.py
+12
-5
upload.py
api/upload.py
+29
-0
urls.py
api/urls.py
+9
-0
No files found.
api/mock/__init__.py
deleted
100644 → 0
View file @
3057fc89
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# __author__ = "chenwei"
# Date: 2018/11/15
api/operation.py
0 → 100644
View file @
db21648e
import
json
from
utils.base
import
APIView
,
get_offset_count
from
utils.logger
import
error_logger
class
TopicHomeRecommendList
(
APIView
):
def
get
(
self
,
request
):
sort_
=
request
.
GET
.
get
(
'sort_params'
,
'-topic_id'
)
offset
,
count
=
get_offset_count
(
request
)
try
:
data
=
self
.
rpc
[
'venus/sun/operation/topic_recommend/list'
](
sort_
=
sort_
,
offset
=
offset
,
count
=
count
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'获取首页推荐帖子列表失败
%
s'
,
e
)
raise
return
data
class
TopicHomeRecommendEdit
(
APIView
):
def
post
(
self
,
request
):
id_
=
request
.
POST
.
get
(
'id'
)
is_online
=
request
.
POST
.
get
(
"is_online"
)
rank
=
request
.
POST
.
get
(
"rank"
)
data
=
{}
if
is_online
is
not
None
:
data
[
"is_online"
]
=
int
(
is_online
)
if
rank
is
not
None
:
data
[
"rank"
]
=
int
(
rank
)
if
not
data
and
not
id_
:
return
{
'message'
:
'参数不全'
}
try
:
self
.
rpc
[
'venus/sun/operation/topic_recommend/edit'
](
id_
=
id_
,
data
=
data
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'更新失败'
,
e
)
raise
return
{
'message'
:
'更新成功'
}
class
TopicHomeFixOperation
(
APIView
):
def
get
(
self
,
request
):
try
:
pos
=
request
.
GET
.
get
(
"pos"
,
4
)
data
=
self
.
rpc
[
'venus/sun/operation/home_fix/info'
](
pos
=
pos
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'运营位获取失败
%
s'
,
e
)
raise
return
{
'data'
:
data
}
def
post
(
self
,
request
):
image
=
request
.
POST
.
get
(
'image'
)
protocol
=
request
.
POST
.
get
(
"protocol"
)
pos
=
request
.
POST
.
get
(
"pos"
,
4
)
if
not
image
or
not
protocol
:
return
{
'message'
:
'参数不全'
}
try
:
self
.
rpc
[
'venus/sun/operation/home_fix/edit'
](
image
=
image
,
protocol
=
protocol
,
pos
=
pos
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'更新失败'
,
e
)
raise
return
{
'message'
:
'更新成功'
}
class
PictorialHomeRecommendList
(
APIView
):
"""获取画报首页运营位推荐画报列表"""
def
get
(
self
,
request
):
offset
,
count
=
get_offset_count
(
request
)
filters
=
json
.
loads
(
request
.
GET
.
get
(
'filters'
,
'{}'
))
sort_by
=
request
.
GET
.
get
(
'sort_by'
,
None
)
try
:
data
=
self
.
rpc
[
'venus/sun/operation/recommend/pictorial/list'
](
filters
=
filters
,
sort_by
=
sort_by
,
offset
=
offset
,
count
=
count
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'获取数据失败'
,
e
)
raise
return
data
class
PictorialHomeRecommendUpdate
(
APIView
):
"""更新画报首页运营位推荐画报"""
def
post
(
self
,
request
):
pictorial_id
=
request
.
POST
.
get
(
'id'
)
rank
=
request
.
POST
.
get
(
'rank'
)
try
:
if
rank
:
data
=
self
.
rpc
[
'venus/sun/operation/recommend/pictorial/rank'
](
pictorial_id
=
pictorial_id
,
rank
=
rank
)
.
unwrap
()
elif
pictorial_id
:
data
=
self
.
rpc
[
'venus/sun/operation/recommend/pictorial/delete'
](
pictorial_id
=
pictorial_id
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'操作失败'
,
e
)
raise
if
not
data
:
return
u'操作失败'
return
data
api/pictorial.py
View file @
db21648e
...
...
@@ -58,7 +58,8 @@ class PictorialUpdateOrCreate(APIView):
'is_recommend'
:
int
(
request
.
POST
.
get
(
'is_recommend'
,
0
)),
'pictorial_user_ids'
:
pictorial_user_ids
,
'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
),
}
try
:
data
=
self
.
rpc
[
'venus/sun/pictorial/edit'
](
id
=
id
,
data
=
data
)
.
unwrap
()
...
...
api/topic.py
View file @
db21648e
...
...
@@ -16,10 +16,17 @@ class TopicListView(APIView):
limit
=
int
(
request
.
GET
.
get
(
'size'
,
10
))
filters
=
json
.
loads
(
request
.
GET
.
get
(
'filter'
,
"{}"
))
sorts_by
=
list
(
map
(
lambda
i
:
int
(
i
),
request
.
GET
.
getlist
(
'sort_params[]'
,
[
3
])))
drop_score
=
request
.
GET
.
get
(
'drop_score'
,
None
)
if
user_id
:
filters
.
update
({
'user_id'
:
user_id
})
if
pictorial_id
:
filters
.
update
({
"pictorial_id"
:
int
(
pictorial_id
)})
if
drop_score
is
not
None
:
if
int
(
drop_score
)
==
0
:
filters
.
update
({
'drop_score'
:
int
(
drop_score
)})
elif
int
(
drop_score
)
==
1
:
filters
.
update
({
'drop_score__gt'
:
int
(
drop_score
)})
res
=
self
.
rpc
[
'physical/search/business/topic'
](
offset
=
(
page
-
1
)
*
limit
,
...
...
@@ -109,7 +116,7 @@ class TopicUpdateOrCreateView(APIView):
def
post
(
self
,
request
):
id
=
request
.
POST
.
get
(
'id'
,
''
)
topic_images
=
list
(
map
(
lambda
x
:
x
[:
-
2
],
json
.
loads
(
request
.
POST
.
get
(
'topic_images'
,
[]
))))
topic_images
=
list
(
map
(
lambda
x
:
x
[:
-
2
],
json
.
loads
(
request
.
POST
.
get
(
'topic_images'
,
'[]'
))))
tag_ids
=
list
(
map
(
lambda
x
:
x
.
split
(
':'
)[
0
],
json
.
loads
(
request
.
POST
.
get
(
'tags'
,
'[]'
))))
collection_tag_ids
=
list
(
map
(
lambda
x
:
x
.
split
(
':'
)[
0
],
json
.
loads
(
request
.
POST
.
get
(
'collection_tags'
,
'[]'
))))
pictorial_ids
=
list
(
json
.
loads
(
request
.
POST
.
get
(
'pictorial_ids'
,
'[]'
)))
...
...
@@ -119,18 +126,18 @@ class TopicUpdateOrCreateView(APIView):
'video_url'
:
request
.
POST
.
get
(
'video_url'
,
''
),
'posting_time'
:
request
.
POST
.
get
(
'posting_time'
),
'content'
:
request
.
POST
.
get
(
'content'
,
''
),
'content_level'
:
request
.
POST
.
get
(
'content_level'
,
''
),
'content_level'
:
request
.
POST
.
get
(
'content_level'
,
0
),
'pictorial_ids'
:
pictorial_ids
,
'user_id'
:
request
.
POST
.
get
(
'user'
,
''
)
.
split
(
':'
)[
0
],
'star_id'
:
request
.
POST
.
get
(
'star'
,
''
)
.
split
(
':'
)[
0
],
'tag_ids'
:
tag_ids
,
'collection_tag_ids'
:
collection_tag_ids
,
'is_online'
:
int
(
request
.
POST
.
get
(
'is_online'
)),
'drop_score'
:
int
(
request
.
POST
.
get
(
'drop_score'
)),
'is_online'
:
int
(
request
.
POST
.
get
(
'is_online'
,
0
)),
'drop_score'
:
int
(
request
.
POST
.
get
(
'drop_score'
,
0
)),
'has_image'
:
1
if
topic_images
else
0
,
'has_video'
:
1
if
request
.
POST
.
get
(
'video_url'
,
''
)
else
0
,
'virtual_vote_num'
:
request
.
POST
.
get
(
'virtual_vote_num'
,
''
),
'is_home'
:
int
(
request
.
POST
.
get
(
'is_home'
,
0
)),
}
try
:
self
.
rpc
[
'venus/sun/topic/edit'
](
id
=
id
,
data
=
data
)
.
unwrap
()
...
...
api/upload.py
View file @
db21648e
...
...
@@ -30,3 +30,32 @@ class FileUpload(APIView):
return
{
'file_url'
:
full_image_url
}
class
FileBatchUpload
(
APIView
):
args_POST
=
{
'img_type'
:
{
'access'
:
int
,
},
}
def
post
(
self
,
request
):
image_type
=
self
.
args_post
.
get
(
'uploadType'
)
image_list
=
request
.
FILES
.
pop
(
'files'
)
result
=
[]
for
image
in
image_list
:
data
=
image
.
read
()
if
image_type
==
FACE_IMAGE_TYPE
:
types
=
str
(
image
)
.
split
(
'.'
)[
-
1
]
full_image_url
,
_
=
upload_file
(
data
,
'face/'
+
str
(
int
(
time
.
time
()))
+
'.'
+
types
)
else
:
full_image_url
=
upload
(
data
,
img_type
=
int
(
image_type
))
+
'-w'
result
.
append
({
'file_url'
:
full_image_url
})
return
result
api/urls.py
View file @
db21648e
...
...
@@ -21,6 +21,7 @@ from .advertise import *
from
.channel_build
import
*
from
.commons
import
*
from
.pictorial
import
*
from
.operation
import
*
from
.tools
import
*
...
...
@@ -135,6 +136,13 @@ urlpatterns = [
# 工具
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
()),
]
search_urlpatterns
=
[
...
...
@@ -150,6 +158,7 @@ search_urlpatterns = [
common_urlpatterns
=
[
url
(
r"^file/upload$"
,
FileUpload
.
as_view
()),
url
(
r"^file/batch/upload$"
,
FileBatchUpload
.
as_view
()),
url
(
r"^get_token/$"
,
QiniuToken
.
as_view
()),
]
...
...
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