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
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
钟尚武
saturn
Commits
db6692de
Commit
db6692de
authored
Dec 28, 2018
by
zhanglu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
标签转化
parent
5cffd8b3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
3 deletions
+13
-3
topic.py
api/views/topic.py
+13
-3
No files found.
api/views/topic.py
View file @
db6692de
import
json
from
api.views.base_view
import
BaseView
from
api.utils.sensitive
import
Sensitive
...
...
@@ -33,7 +32,8 @@ class CreateTopicForBatch(BaseView):
tag_names
=
[]
for
item
in
topics
:
tag_names
.
extend
(
item
.
get
(
"tags"
,
[]))
tags
=
item
.
get
(
"tags"
)
or
[]
tag_names
.
extend
([
tag
.
replace
(
"#"
,
''
)
.
strip
()
for
tag
in
tags
])
item
[
"user_id"
]
=
user_id
check_info
=
Sensitive
.
check
(
tag_names
)
...
...
@@ -48,10 +48,20 @@ class CreateTopicForBatch(BaseView):
return
self
.
error
(
_tag_error
)
# 更新发帖
# 处理标签,将文本中的标签处理成现有标签
for
item
in
topics
:
tags
=
item
.
get
(
"tags"
)
or
[]
tags
=
[
tag
.
replace
(
"#"
,
''
)
.
strip
()
for
tag
in
tags
]
content
=
item
[
"content"
]
for
tag_name
,
tag_id
in
_tag_data
.
items
():
if
tag_name
in
tags
:
alpha_tag
=
'<topic>{'
+
'"id":{},"name":"{}"'
.
format
(
tag_id
,
tag_name
)
+
'}</topic>'
content
=
content
.
replace
(
'#'
+
tag_name
,
alpha_tag
)
item
[
"content"
]
=
content
.
replace
(
'#'
,
''
)
item
[
"tag_ids"
]
=
[
_tag_data
[
tag_name
]
for
tag_name
in
item
.
get
(
"tags"
,
[])
if
_tag_data
.
get
(
tag_name
)
for
tag_name
in
tags
if
_tag_data
.
get
(
tag_name
)
]
create_err
,
result
=
self
.
call_rpc
(
...
...
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