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
9fa02039
Commit
9fa02039
authored
Apr 04, 2019
by
杨成林
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' into 'test'
Dev See merge request
!166
parents
42bea5db
a3ae7dc5
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
70 additions
and
19 deletions
+70
-19
channel_build.py
api/channel_build.py
+12
-7
operation.py
api/operation.py
+42
-2
pictorial.py
api/pictorial.py
+2
-1
search.py
api/search.py
+2
-2
topic.py
api/topic.py
+6
-4
urls.py
api/urls.py
+2
-0
channel_package_tools.py
utils/channel_package_tools.py
+4
-3
No files found.
api/channel_build.py
View file @
9fa02039
import
hashlib
import
time
from
django.conf
import
settings
from
gm_types.ascle
import
ERROR
...
...
@@ -52,7 +53,8 @@ class ChannelList(APIView):
error_logger
.
error
(
u'获取渠道列表失败:
%
s'
,
e
)
raise
e
data
=
{
'total'
:
channel_list
.
get
(
'total'
,
0
)}
url
=
settings
.
APK_DOMAIN
+
settings
.
APK_BUILD_DIR
+
'/'
+
settings
.
APK_RELEASE_DIR
+
"/{name}/gm_alpha_{name}.apk"
url
=
settings
.
APK_DOMAIN
+
settings
.
APK_BUILD_DIR
+
'/'
+
settings
.
APK_RELEASE_DIR
+
\
"/{name}/gm_alpha_{name}.apk?t={timestamp}"
channels
=
[
{
'id'
:
data
.
get
(
'id'
),
...
...
@@ -60,7 +62,7 @@ class ChannelList(APIView):
'url_name'
:
data
.
get
(
'url_name'
),
'pack'
:
data
.
get
(
'pack'
),
'released_version'
:
data
.
get
(
'released_version'
),
'download_url'
:
url
.
format
(
name
=
data
.
get
(
'url_name'
)),
'download_url'
:
url
.
format
(
name
=
data
.
get
(
'url_name'
)
,
timestamp
=
time
.
time
()
),
}
for
data
in
channel_list
.
get
(
'data'
,
[])]
data
.
update
({
'channel'
:
channels
})
...
...
@@ -84,7 +86,7 @@ class ChannelVersionList(APIView):
error_logger
.
error
(
u'获取渠道列表失败:
%
s'
,
e
)
raise
e
data
=
{
'total'
:
channel_list
.
get
(
'total'
,
0
)}
url
=
settings
.
APK_DOMAIN
+
settings
.
APK_BUILD_DIR
+
"/{version}/{name}/gm_alpha_{name}.apk"
url
=
settings
.
APK_DOMAIN
+
settings
.
APK_BUILD_DIR
+
"/{version}/{name}/gm_alpha_{name}.apk
?t={timestamp}
"
channels
=
[
{
'version_id'
:
data
.
get
(
'version_id'
),
...
...
@@ -96,7 +98,8 @@ class ChannelVersionList(APIView):
'packed'
:
data
.
get
(
'packed'
),
'release_time'
:
data
.
get
(
'release_time'
),
'is_released'
:
data
.
get
(
'is_released'
),
'download_url'
:
url
.
format
(
version
=
data
.
get
(
'version'
),
name
=
data
.
get
(
'url_name'
)),
'download_url'
:
url
.
format
(
version
=
data
.
get
(
'version'
),
name
=
data
.
get
(
'url_name'
),
timestamp
=
time
.
time
()),
}
for
data
in
channel_list
.
get
(
'data'
,
[])]
data
.
update
({
'channel'
:
channels
})
...
...
@@ -245,7 +248,8 @@ class VersionChannelList(APIView):
error_logger
.
error
(
u'获取版本列表失败:
%
s'
,
e
)
raise
e
data
=
{
'total'
:
version_list
.
get
(
'total'
,
0
)}
url
=
settings
.
APK_DOMAIN
+
settings
.
APK_BUILD_DIR
+
"/{version}/{name}/gm_alpha_{name}.apk"
url
=
settings
.
APK_DOMAIN
+
settings
.
APK_BUILD_DIR
+
"/{version}/{name}/gm_alpha_{name}.apk?t={timestamp}"
sup_url
=
ChannelPackage
.
apk_url
(
channel
=
''
,
version
=
version_list
.
get
(
'version'
))
+
'?t={timestamp}'
versions
=
{
'version'
:
[{
'channel_id'
:
item
.
get
(
'channel_id'
),
...
...
@@ -254,11 +258,12 @@ class VersionChannelList(APIView):
'name'
:
item
.
get
(
'name'
),
'packed_time'
:
item
.
get
(
'packed_time'
),
'packed'
:
item
.
get
(
'packed'
),
'download_url'
:
url
.
format
(
version
=
item
.
get
(
'version'
),
name
=
item
.
get
(
'url_name'
)),
'download_url'
:
url
.
format
(
version
=
item
.
get
(
'version'
),
name
=
item
.
get
(
'url_name'
),
timestamp
=
time
.
time
()),
'release_time'
:
item
.
get
(
'release_time'
),
'is_released'
:
item
.
get
(
'is_released'
),
}
for
item
in
version_list
.
get
(
'data'
,
[])],
'base_apk_url'
:
ChannelPackage
.
apk_url
(
channel
=
''
,
version
=
version_list
.
get
(
'version'
)),
'base_apk_url'
:
sup_url
.
format
(
timestamp
=
time
.
time
(
)),
}
data
.
update
({
'data'
:
versions
})
return
self
.
write_success
(
data
=
data
)
...
...
api/operation.py
View file @
9fa02039
import
json
from
utils.base
import
APIView
,
get_offset_count
from
utils.logger
import
error_logger
...
...
@@ -6,7 +7,7 @@ class TopicHomeRecommendList(APIView):
def
get
(
self
,
request
):
sort_
=
request
.
GET
.
get
(
'sort'
,
'-topic_id'
)
sort_
=
request
.
GET
.
get
(
'sort
_params
'
,
'-topic_id'
)
offset
,
count
=
get_offset_count
(
request
)
try
:
...
...
@@ -16,7 +17,7 @@ class TopicHomeRecommendList(APIView):
error_logger
.
error
(
u'获取首页推荐帖子列表失败
%
s'
,
e
)
raise
return
{
'data'
:
data
}
return
data
class
TopicHomeRecommendEdit
(
APIView
):
...
...
@@ -79,3 +80,42 @@ class TopicHomeFixOperation(APIView):
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 @
9fa02039
...
...
@@ -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/search.py
View file @
9fa02039
...
...
@@ -35,7 +35,7 @@ class TagSearchView(APIView):
def
get
(
self
,
request
):
offset
,
count
=
get_offset_count
(
request
)
name
=
request
.
GET
.
get
(
'name'
)
platform
=
request
.
GET
.
get
(
'platform'
)
platform
=
None
#
request.GET.get('platform')
collection
=
request
.
GET
.
get
(
'collection'
)
try
:
data
=
self
.
rpc
[
'venus/sun/tag/search'
](
offset
=
offset
,
count
=
count
,
name
=
name
,
platform
=
platform
,
collection
=
collection
)
.
unwrap
()
...
...
@@ -93,7 +93,7 @@ class TagTypeSearchView(APIView):
'data'
:
[
'{id}:{name}'
.
format
(
id
=
search_data
[
'id'
],
name
=
search_data
[
'name'
])
for
search_data
in
data
]
}
class
PictorialSearchView
(
APIView
):
def
get
(
self
,
request
):
name
=
request
.
GET
.
get
(
'name'
)
...
...
api/topic.py
View file @
9fa02039
...
...
@@ -116,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'
,
'[]'
)))
...
...
@@ -126,16 +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/urls.py
View file @
9fa02039
...
...
@@ -137,6 +137,8 @@ urlpatterns = [
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
=
[
...
...
utils/channel_package_tools.py
View file @
9fa02039
...
...
@@ -63,9 +63,8 @@ class ChannelPackage(object):
ret_res
=
cmd_res
.
readlines
()[
0
]
target_channel_info
=
cp
.
findall
(
ret_res
)[
1
]
if
target_channel_info
and
channel_name
==
target_channel_info
.
split
(
'='
)[
1
]:
target_path
=
self
.
channel_prefix
+
'_'
+
channel_name
+
'.apk'
os
.
remove
(
self
.
apk
)
return
targe
t_path
return
targe
_apk
else
:
log_error
()
os
.
remove
(
self
.
apk
)
...
...
@@ -76,6 +75,8 @@ class ChannelPackage(object):
apk_uri
=
self
.
apk_key
(
channel_name
,
self
.
version
)
QiniuTool
.
delete
(
apk_uri
,
settings
.
APK_SCOPE
)
ret
=
QiniuFileTool
.
upload_file
(
chn_apk_path
,
apk_uri
,
settings
.
APK_SCOPE
)
res_resp
=
QiniuTool
.
refresh
([
'http://alpha-s.iyanzhi.com/'
+
apk_uri
])
info_logger
.
debug
(
res_resp
)
os
.
remove
(
chn_apk_path
)
return
ret
...
...
@@ -115,5 +116,5 @@ class ChannelPackage(object):
QiniuTool
.
delete
(
current_key
,
apk_scope
)
QiniuTool
.
copy
(
version_key
,
current_key
,
apk_scope
,
apk_scope
)
if
need_refresh
:
QiniuTool
.
refresh
([
'http://
qiniu.dl.igengme
i.com/'
+
current_key
])
QiniuTool
.
refresh
([
'http://
alpha-s.iyanzh
i.com/'
+
current_key
])
return
True
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