Commit 36d813d5 authored by haowang's avatar haowang

fix

parents 929831a5 faf7b6f7
......@@ -19,7 +19,7 @@ class CreateTagForBatch(BaseView):
for tag in tag_list:
succ = check_info.get(tag) if tag else True
if not succ:
tags.append(tag)
tags.append({"name": tag})
else:
tags = tag_list
error, data = self.call_rpc('venus/community/tag/batch_create_not_classify', data=tags)
......
......@@ -57,6 +57,7 @@ class CreateTopicForBatch(BaseView):
if not topics:
return self.ok()
location_tags = []
tag_names = []
for item in topics:
tags = item.get("tags") or []
......@@ -65,6 +66,14 @@ class CreateTopicForBatch(BaseView):
item["card_level"] = card_level
item["tag_id"] = tag_id if tag_id else None
item["is_online"] = is_online
if item.get("location") and item.get("location").get("name"):
_tag_error, _location_tag_data = self.call_rpc(
"venus/community/tag/batch_create_tag_by_name",
tags=tags, is_location=1, is_own=1,
)
if _tag_error:
return self.error(_tag_error)
location_tags.append(_location_tag_data)
not_exists_ids = []
topic_list = []
......@@ -92,7 +101,7 @@ class CreateTopicForBatch(BaseView):
# check_info = Sensitive.check(tag_names)
# tags = [tag_name for tag_name, succ in check_info.items() if not succ]
tags = tag_names
tags = tag_names
# 先创建标签
_tag_error, _tag_data = self.call_rpc(
......@@ -101,12 +110,17 @@ class CreateTopicForBatch(BaseView):
)
if _tag_error:
return self.error(_tag_error)
_tag_data.extend(location_tags)
# 更新发帖
# 处理标签,将文本中的标签处理成现有标签
for item in topic_list:
tags = item.get("tags") or []
tags = [tag.replace("#", '').strip() for tag in tags]
#添加地域标签
if item.get("location") and item.get("location").get("name"):
tags.append(item.get("location").get("name"))
content = item["content"]
for tag_name, tag_id in _tag_data.items():
if tag_name in tags:
......@@ -181,12 +195,12 @@ class CreateTopicForBatchByOne(BaseView):
# check_info = Sensitive.check(tag_names)
# tags = [tag_name for tag_name, succ in check_info.items() if not succ]
# check_info = Sensitive.check(tag_names)
tags = tag_names
tags = [{"name": item} for item in tag_names]
# 先创建标签
_tag_error, _tag_data = self.call_rpc(
"venus/community/tag/batch_create_tag_by_name",
tag_names=tags
tags=tags
)
if _tag_error:
return self.error(_tag_error)
......
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