Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
saturn
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
saturn
Commits
9ea773c2
Commit
9ea773c2
authored
Dec 23, 2018
by
王浩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add tag create_tag_for_batch api
parent
621ca4bd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
3 deletions
+20
-3
urls.py
api/urls.py
+2
-0
tag.py
api/views/tag.py
+18
-3
No files found.
api/urls.py
View file @
9ea773c2
...
...
@@ -3,8 +3,10 @@ from django.conf.urls import url
from
.views
import
user
from
.views
import
topic
from
.views
import
tag
urlpatterns
=
[
url
(
r'^v1/update_grasp_status$'
,
user
.
UpdateGraspStatus
.
as_view
(),
name
=
'update_grasp_status$'
),
url
(
r'^v1/create_topic_for_batch$'
,
topic
.
CreateTopicForBatch
.
as_view
(),
name
=
'create_topic_for_batch'
),
url
(
r'^v1/create_tag_for_batch$'
,
tag
.
CreateTagForBatch
.
as_view
(),
name
=
'create_tag_for_batch'
),
]
api/views/tag.py
View file @
9ea773c2
import
json
from
api.views.base_view
import
BaseView
from
api.utils.sensitive
import
Sensitive
class
CreateTagForBatch
(
BaseView
):
...
...
@@ -8,5 +9,20 @@ class CreateTagForBatch(BaseView):
内部使用,批量建标签
"""
def
post
(
self
,
request
):
topic_list
=
json
.
loads
(
request
.
POST
.
get
(
"tag_list"
,
'[]'
))
\ No newline at end of file
tag_list
=
json
.
loads
(
request
.
POST
.
get
(
"tags"
,
'[]'
))
print
(
request
.
POST
)
tags
=
[]
# 敏感词检测,获取可用的帖子
check_info
=
Sensitive
.
check
([
item
[
"name"
]
for
item
in
tag_list
if
item
.
get
(
"name"
)])
for
tag
in
tag_list
:
succ
=
check_info
.
get
(
tag
.
get
(
"name"
))
if
tag
.
get
(
"name"
)
else
True
if
not
succ
:
tags
.
append
(
tag
)
error
,
data
=
self
.
call_rpc
(
'venus/community/tag/batch_create_not_classify'
,
data
=
tags
)
if
error
:
return
self
.
error
(
error
)
return
self
.
ok
(
data
=
data
)
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