Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
sun
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
1
Merge Requests
1
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
alpha
sun
Commits
7c51726e
Commit
7c51726e
authored
Nov 27, 2019
by
zhongshangwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加快捷评论模块
parent
30be8701
Pipeline
#5151
passed with stage
Changes
2
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
0 deletions
+62
-0
tag.py
api/tag.py
+59
-0
urls.py
api/urls.py
+3
-0
No files found.
api/tag.py
View file @
7c51726e
...
...
@@ -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
}
api/urls.py
View file @
7c51726e
...
...
@@ -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
()),
...
...
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