Commit c5b3fab5 authored by 钟尚武's avatar 钟尚武

Merge branch 'quick-reply' into 'deploy/like-test'

增加快捷评论模块

See merge request !410
parents 2554c513 7c51726e
Pipeline #5153 passed with stage
......@@ -343,3 +343,62 @@ class TagSetUpdateOrCreateView(APIView):
"message": "创建成功",
"code": 200
}
def filter_quick_replys(contents):
return [content for content in contents if content]
class TagSetQuickReplyView(APIView):
def post(self, request):
tag_set_id = request.POST.get("id")
quick_replys = json.loads(request.POST.get('quick_replys', ''))
quick_replys = filter_quick_replys(quick_replys)
if any([len(item) > 100 for item in quick_replys]):
return {
"message": "快捷评论最多允许输入100字",
"code": 400
}
try:
data = self.rpc['venus/sun/tag_set/quick_reply'](quick_replys=quick_replys).unwrap()
except Exception as e:
error_logger.error(u'获取快捷评论失败%s', e)
raise
return data
class NormalQuickReplyListView(APIView):
""" 通用快捷评论列表 """
def get(self, request):
try:
data = self.rpc['venus/sun/quick_reply/list']().unwrap()
except Exception as e:
error_logger.error(u'获取通用快捷评论失败%s', e)
raise
return data
class NormalQuickReplyCreateView(APIView):
""" 创建通用快捷评论 """
def post(self, request):
quick_replys = json.loads(request.POST.get('quick_replys', ''))
quick_replys = filter_quick_replys(quick_replys)
if any([len(item) > 100 for item in quick_replys]):
return {
"message": "快捷评论最多允许输入100字",
"code": 400
}
try:
data = self.rpc['venus/sun/quick_reply/create'](quick_replys=quick_replys).unwrap()
except Exception as e:
error_logger.error(u'创建快捷评论失败%s', e)
raise
return {
"message": "创建成功",
"code": 200
}
......@@ -124,6 +124,9 @@ urlpatterns = [
url(r'^tag_set/list$', TagSetListView.as_view()),
url(r'^tag_set/create$', TagSetUpdateOrCreateView.as_view()),
url(r'^tag_set/delete$', TagSetDeleteView.as_view()),
url(r'^tag_set/quick_reply$', TagSetQuickReplyView.as_view()),
url(r'^quick_reply/list$', NormalQuickReplyListView.as_view()),
url(r'^quick_reply/create$', NormalQuickReplyCreateView.as_view()),
# 扫脸相关
url(r'^face/star/create$', FaceStarEdit.as_view()),
......
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