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
958fc338
Commit
958fc338
authored
6 years ago
by
王浩
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'haow/dev' into 'dev'
Haow/dev See merge request
!191
parents
9f0d4c07
266cb0b3
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
2 deletions
+32
-2
account.py
api/account.py
+8
-2
pictorial.py
api/pictorial.py
+1
-0
tools.py
api/tools.py
+20
-0
topic.py
api/topic.py
+2
-0
urls.py
api/urls.py
+1
-0
No files found.
api/account.py
View file @
958fc338
...
...
@@ -75,7 +75,10 @@ class LoginView(APIView):
'avatar'
:
settings
.
AVATAR
})
if
data
[
'is_staff'
]:
data
.
update
({
'roles'
:
[
'staff'
]})
if
data
.
get
(
'staff_level'
):
data
.
update
({
'roles'
:
[
'mbhoperator'
]})
else
:
data
.
update
({
'roles'
:
[
'staff'
]})
else
:
data
.
update
({
'roles'
:
[
'anonymous'
]})
except
Exception
as
e
:
...
...
@@ -114,7 +117,10 @@ class LoginView(APIView):
error_logger
.
error
(
u'登陆失败
%
s'
,
e
)
raise
if
data
[
'is_staff'
]:
ret
.
update
({
'roles'
:
[
'staff'
]})
if
data
.
get
(
'staff_level'
):
ret
.
update
({
'roles'
:
[
'mbhoperator'
]})
else
:
ret
.
update
({
'roles'
:
[
'staff'
]})
else
:
ret
.
update
({
'roles'
:
[
'anonymous'
]})
return
{
...
...
This diff is collapsed.
Click to expand it.
api/pictorial.py
View file @
958fc338
...
...
@@ -61,6 +61,7 @@ class PictorialUpdateOrCreate(APIView):
'collection_tag_ids'
:
collection_tag_ids
,
'is_home_recommend'
:
int
(
request
.
POST
.
get
(
'is_home_recommend'
,
0
)),
'add_score'
:
int
(
request
.
POST
.
get
(
'add_score'
,
0
)),
'is_public'
:
True
if
request
.
POST
.
get
(
'is_public'
)
==
"true"
else
False
}
try
:
...
...
This diff is collapsed.
Click to expand it.
api/tools.py
View file @
958fc338
import
time
import
json
from
utils.base
import
APIView
from
gm_upload
import
upload
,
upload_file
from
openpyxl
import
load_workbook
...
...
@@ -71,3 +72,22 @@ class BatchUpdateTopicTag(APIView):
self
.
rpc
[
'venus/sun/tools/batch_update_topic_tags'
](
topic_infos
=
topic_infos
)
.
unwrap
()
return
{
'message'
:
u'上传成功'
,
'code'
:
200
}
class
BatchCreateTopicWithAiFashionTag
(
APIView
):
def
post
(
self
,
request
):
json_file
=
request
.
FILES
.
get
(
'file'
)
tag_infos
=
request
.
POST
.
get
(
'tag_infos'
,
'[]'
)
if
not
json_file
and
not
tag_infos
:
return
{
'message'
:
u'上传失败,请重新上传'
,
'code'
:
500
}
if
json_file
:
json_data
=
json
.
load
(
json_file
)
self
.
rpc
[
'venus/sun/tools/batch_create_topic_with_ai_fashion_tag'
](
infos
=
json_data
)
.
unwrap
()
if
tag_infos
:
json_data
=
json
.
loads
(
tag_infos
)
self
.
rpc
[
'venus/sun/tools/batch_create_topic_with_ai_fashion_tag'
](
infos
=
json_data
)
.
unwrap
()
return
{
'message'
:
u'上传成功'
,
'code'
:
200
}
This diff is collapsed.
Click to expand it.
api/topic.py
View file @
958fc338
...
...
@@ -119,6 +119,7 @@ class TopicUpdateOrCreateView(APIView):
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'
,
'[]'
))))
cut_word_tag_ids
=
list
(
map
(
lambda
x
:
x
.
split
(
':'
)[
0
],
json
.
loads
(
request
.
POST
.
get
(
'cut_word_tags'
,
'[]'
))))
pictorial_ids
=
list
(
json
.
loads
(
request
.
POST
.
get
(
'pictorial_ids'
,
'[]'
)))
data
=
{
...
...
@@ -132,6 +133,7 @@ class TopicUpdateOrCreateView(APIView):
'star_id'
:
request
.
POST
.
get
(
'star'
,
''
)
.
split
(
':'
)[
0
],
'tag_ids'
:
tag_ids
,
'collection_tag_ids'
:
collection_tag_ids
,
'cut_word_tag_ids'
:
cut_word_tag_ids
,
'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
,
...
...
This diff is collapsed.
Click to expand it.
api/urls.py
View file @
958fc338
...
...
@@ -144,6 +144,7 @@ urlpatterns = [
# 工具
url
(
r'^tools/virtual_vote$'
,
VirtualVote
.
as_view
()),
url
(
r'^tools/batch_update_topic_tag$'
,
BatchUpdateTopicTag
.
as_view
()),
url
(
r'^tools/batch_create_topic_with_ai_fashion_tag$'
,
BatchCreateTopicWithAiFashionTag
.
as_view
()),
]
...
...
This diff is collapsed.
Click to expand it.
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