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
0
Merge Requests
0
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
钟尚武
sun
Commits
db465f29
Commit
db465f29
authored
May 09, 2019
by
王浩
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'haow/dev' into 'master'
add tag filter func See merge request
alpha/sun!196
parents
287cffc5
e2ff46d6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
1 deletion
+58
-1
tag.py
api/tag.py
+55
-1
urls.py
api/urls.py
+3
-0
No files found.
api/tag.py
View file @
db465f29
...
...
@@ -4,7 +4,7 @@
# Date: 2018/11/17
import
json
from
utils.base
import
APIView
from
utils.base
import
APIView
,
get_offset_count
from
utils.logger
import
error_logger
...
...
@@ -144,3 +144,57 @@ class TagRegisterUpdateView(APIView):
error_logger
.
error
(
u'配置失败'
)
raise
return
{
'msg'
:
'更改成功'
}
class
TagFilterList
(
APIView
):
def
get
(
self
,
request
):
filters
=
{}
offset
,
count
=
get_offset_count
(
request
)
tag_name
=
request
.
GET
.
get
(
'tag_name'
,
None
)
tag_id
=
request
.
GET
.
get
(
'tag_id'
,
None
)
if
tag_name
:
filters
[
'tag_name'
]
=
tag_name
if
tag_id
and
int
(
tag_id
)
>
0
:
filters
[
'tag_id'
]
=
tag_id
data
=
self
.
rpc
[
'venus/sun/tag/filter/list'
](
filters
=
filters
,
offset
=
offset
,
count
=
count
)
.
unwrap
()
return
data
class
TagFilterCreate
(
APIView
):
def
post
(
self
,
request
):
tag_infos
=
json
.
loads
(
request
.
POST
.
get
(
'tag_infos'
,
'[]'
))
if
not
tag_infos
:
return
{
'message'
:
'参数不完整'
}
for
tag_info
in
tag_infos
:
tag_name
=
tag_info
.
get
(
'tag_name'
,
None
)
tag_id
=
tag_info
.
get
(
'tag_id'
,
None
)
if
not
tag_id
or
not
tag_name
:
return
{
'message'
:
'参数不完整'
}
data
=
self
.
rpc
[
'venus/sun/tag/filter/add'
](
tag_id
=
tag_id
,
tag_name
=
tag_name
)
.
unwrap
()
if
not
data
:
return
{
'message'
:
'创建失败'
}
return
{
'message'
:
'创建成功'
}
class
TagFilterDelete
(
APIView
):
def
post
(
self
,
request
):
ids
=
json
.
loads
(
request
.
POST
.
get
(
'ids'
,
'[]'
))
if
not
ids
:
return
{
'message'
:
'参数不完整'
}
for
id_
in
ids
:
data
=
self
.
rpc
[
'venus/sun/tag/filter/delete'
](
id_
=
id_
)
.
unwrap
()
if
not
data
:
return
{
'message'
:
'操作失败'
}
return
{
'message'
:
'操作成功'
}
api/urls.py
View file @
db465f29
...
...
@@ -88,6 +88,9 @@ urlpatterns = [
url
(
r'^tag/create$'
,
TagUpdateOrCreateView
.
as_view
()),
url
(
r'^tag/detail$'
,
TagUpdateOrCreateView
.
as_view
()),
url
(
r'^tag/register_show/update$'
,
TagRegisterUpdateView
.
as_view
()),
url
(
r'^tag/filter/list$'
,
TagFilterList
.
as_view
()),
url
(
r'^tag/filter/add$'
,
TagFilterCreate
.
as_view
()),
url
(
r'^tag/filter/delete$'
,
TagFilterDelete
.
as_view
()),
# 标签类型相关
url
(
r'^tag/tagtype/list$'
,
TagTypeListView
.
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