Commit 065e2c3b authored by 王浩's avatar 王浩

Merge branch 'haow/dev' into 'dev'

Haow/dev

See merge request !23
parents 5abc8c42 ee1eaf07
......@@ -18,4 +18,5 @@ urlpatterns = [
# user
url(r'^v1/user/shadow/list$', user.ShadowUserList.as_view(), name='create_tag_for_batch'),
url(r'^v1/validate_3party_account$', user.Validate3PartyAccount.as_view(), name='validate_3party_account$'),
]
......@@ -93,11 +93,20 @@ class Sensitive(object):
if not data or "detail" in data: # 程序出错啦
return
action = data.get("result", {}).get("action", 0)
result = data.get("result", {})
if result:
action = result.get("action", 0)
else:
action = 0
if action == 0 or action == 1: # "通过"
return []
lables = data.get("result", {}).get("labels", [])
if result:
lables = result.get("labels", [])
else:
lables = []
for lable in lables:
hints.extend(lable.get('details', {}).get("hint"))
......
......@@ -10,14 +10,18 @@ class CreateTagForBatch(BaseView):
"""
def post(self, request):
tag_list = json.loads(request.POST.get("tags", '[]'))
need_check = request.POST.get('need_check', 0)
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)
if need_check:
# 敏感词检测,获取可用的帖子
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)
else:
tags = tag_list
error, data = self.call_rpc('venus/community/tag/batch_create_not_classify', data=tags)
......
......@@ -30,12 +30,18 @@ class CreateTopicForBatch(BaseView):
topics = []
# 敏感词检测,获取可用的帖子
check_info = Sensitive.check([topic["content"] for topic in topic_list if topic.get("content")])
# check_info = Sensitive.check([topic["content"] for topic in topic_list if topic.get("content")])
# for topic in topic_list:
# if topic.get('content'):
# succ = check_info.get(topic.get("content"))
# if not succ:
# topics.append(topic)
# else:
# if topic.get('images') or topic.get('video'):
# topics.append(topic)
for topic in topic_list:
if topic.get('content'):
succ = check_info.get(topic.get("content"))
if not succ:
topics.append(topic)
topics.append(topic)
else:
if topic.get('images') or topic.get('video'):
topics.append(topic)
......@@ -49,11 +55,12 @@ class CreateTopicForBatch(BaseView):
tag_names.extend([tag.replace("#", '').strip() for tag in tags])
item["user_id"] = user_id
item["card_level"] = card_level
item["tag_id"] = tag_id
item["tag_id"] = tag_id if tag_id else None
item["is_online"] = is_online
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_name for tag_name, succ in check_info.items() if not succ]
tags = tag_names
# 先创建标签
_tag_error, _tag_data = self.call_rpc(
......@@ -107,12 +114,19 @@ class CreateTopicForBatchByOne(BaseView):
topics = []
# 敏感词检测,获取可用的帖子
check_info = Sensitive.check([topic["content"] for topic in topic_list if topic.get("content")])
# check_info = Sensitive.check([topic["content"] for topic in topic_list if topic.get("content")])
# for topic in topic_list:
# if topic.get('content'):
# succ = check_info.get(topic.get("content"))
# if not succ:
# topics.append(topic)
# else:
# if topic.get('images') or topic.get('video'):
# topics.append(topic)
for topic in topic_list:
if topic.get('content'):
succ = check_info.get(topic.get("content"))
if not succ:
topics.append(topic)
topics.append(topic)
else:
if topic.get('images') or topic.get('video'):
topics.append(topic)
......@@ -128,8 +142,10 @@ class CreateTopicForBatchByOne(BaseView):
item["user_id"] = user_id
need_create_topics.append(item)
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_name for tag_name, succ in check_info.items() if not succ]
# check_info = Sensitive.check(tag_names)
tags = tag_names
# 先创建标签
_tag_error, _tag_data = self.call_rpc(
......
import json
from api.views.base_view import BaseView, get_offset_count
......@@ -38,3 +40,22 @@ class ShadowUserList(BaseView):
}
return self.ok(data=result)
class Validate3PartyAccount(BaseView):
"""
验证三方账号是否已绑定过
"""
def post(self, request):
_ids = request.POST.get("account_ids") or '[]'
account_ids = json.loads(_ids)
err, _data = self.call_rpc(
"venus/community/user/validate_has_bind_3party_account",
bind_account_ids=account_ids
)
if err:
return self.error(err)
data = {account_id: _data.get(account_id, False) for account_id in account_ids}
return self.ok(data=data)
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