Commit 1ff1946b authored by 王浩's avatar 王浩

Merge branch 'haow/batch_create_topic' into 'master'

fix topic batch create get content

See merge request !50
parents d044d3e3 d9df8fd3
...@@ -123,12 +123,12 @@ class CreateTopicForBatch(BaseView): ...@@ -123,12 +123,12 @@ class CreateTopicForBatch(BaseView):
#添加地域标签 #添加地域标签
if item.get("location") and item.get("location").get("name"): if item.get("location") and item.get("location").get("name"):
tags.append(item.get("location").get("name")) tags.append(item.get("location").get("name"))
content = item["content"] content = item.get("content")
for tag_name, tag_id in _tag_data.items(): for tag_name, tag_id in _tag_data.items():
if tag_name in tags: if tag_name in tags:
alpha_tag = '<topic>{' + '"id":{},"name":"{}"'.format(tag_id, tag_name) + '}</topic>' alpha_tag = '<topic>{' + '"id":{},"name":"{}"'.format(tag_id, tag_name) + '}</topic>'
content = content.replace('#' + tag_name, alpha_tag) content = content.replace('#' + tag_name, alpha_tag)
item["content"] = content.replace('#', '') item.get("content") = content.replace('#', '')
item["tag_ids"] = [ item["tag_ids"] = [
_tag_data[tag_name] _tag_data[tag_name]
...@@ -212,12 +212,12 @@ class CreateTopicForBatchByOne(BaseView): ...@@ -212,12 +212,12 @@ class CreateTopicForBatchByOne(BaseView):
for item in need_create_topics: for item in need_create_topics:
tags = item.get("tags") or [] tags = item.get("tags") or []
tags = [tag.replace("#", '').strip() for tag in tags] tags = [tag.replace("#", '').strip() for tag in tags]
content = item["content"] content = item.get("content")
for tag_name, tag_id in _tag_data.items(): for tag_name, tag_id in _tag_data.items():
if tag_name in tags: if tag_name in tags:
alpha_tag = '<topic>{' + '"id":{},"name":"{}"'.format(tag_id, tag_name) + '}</topic>' alpha_tag = '<topic>{' + '"id":{},"name":"{}"'.format(tag_id, tag_name) + '}</topic>'
content = content.replace('#' + tag_name, alpha_tag) content = content.replace('#' + tag_name, alpha_tag)
item["content"] = content.replace('#', '') item.get("content") = content.replace('#', '')
item["tag_ids"] = [ item["tag_ids"] = [
_tag_data[tag_name] _tag_data[tag_name]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment