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
1682a6ae
Commit
1682a6ae
authored
Mar 21, 2019
by
王浩
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'haow/dev' into 'test'
fix See merge request
!129
parents
ca13dc89
3040a6c4
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
13 additions
and
148 deletions
+13
-148
group.py
api/group.py
+0
-112
push.py
api/push.py
+3
-3
search.py
api/search.py
+0
-13
star.py
api/star.py
+2
-2
urls.py
api/urls.py
+2
-12
user.py
api/user.py
+6
-6
No files found.
api/group.py
deleted
100644 → 0
View file @
ca13dc89
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# __author__ = "chenwei"
# Date: 2018/11/15
import
json
from
utils.base
import
APIView
from
utils.logger
import
error_logger
class
GroupListView
(
APIView
):
def
get
(
self
,
request
):
star_id
=
request
.
GET
.
get
(
'star_id'
)
user_id
=
request
.
GET
.
get
(
'user_id'
)
offset
=
int
(
request
.
GET
.
get
(
'page'
,
0
))
limit
=
int
(
request
.
GET
.
get
(
'limit'
,
10
))
filters
=
self
.
handle_filter
(
request
.
GET
.
get
(
'filter'
,
""
))
if
star_id
:
filters
.
update
({
'star_id'
:
star_id
})
if
user_id
:
filters
.
update
({
'user_id'
:
user_id
})
try
:
data
=
self
.
rpc
[
'venus/sun/group/list'
](
filters
=
filters
,
offset
=
(
offset
-
1
)
*
limit
,
limit
=
limit
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'获取小组列表失败
%
s'
,
e
)
raise
return
data
def
post
(
self
,
request
):
ids
=
json
.
loads
(
request
.
POST
.
get
(
'ids'
,
'[]'
))
updates
=
json
.
loads
(
request
.
POST
.
get
(
'updates'
,
'{}'
))
try
:
self
.
rpc
[
'venus/sun/group/batch/update'
](
updates
=
updates
,
ids
=
ids
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'批量更新失败
%
s'
,
e
)
raise
return
{
"message"
:
"更新成功"
}
class
GroupUpdateOrCreate
(
APIView
):
def
get
(
self
,
request
):
id
=
request
.
GET
.
get
(
'id'
)
.
split
(
':'
)[
0
]
try
:
data
=
self
.
rpc
[
'venus/sun/group/get'
](
id
=
id
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'获取
%
s用户信息失败
%
s'
%
(
id
,
e
))
raise
return
data
def
post
(
self
,
request
):
id
=
request
.
POST
.
get
(
'id'
)
star_ids
=
list
(
map
(
lambda
x
:
x
.
split
(
":"
)[
0
],
json
.
loads
(
request
.
POST
.
get
(
'star'
,
'[]'
))))
group_user_ids
=
list
(
map
(
lambda
x
:
x
.
split
(
":"
)[
0
],
json
.
loads
(
request
.
POST
.
get
(
'group_users'
,
'[]'
))))
data
=
{
'name'
:
request
.
POST
.
get
(
'name'
,
''
),
'description'
:
request
.
POST
.
get
(
'description'
,
''
),
'creator_id'
:
request
.
POST
.
get
(
'user'
,
''
)
.
split
(
':'
)[
0
],
'celebrity_ids'
:
star_ids
,
'is_online'
:
int
(
request
.
POST
.
get
(
'is_online'
,
0
)),
'is_recommend'
:
int
(
request
.
POST
.
get
(
'is_recommend'
,
0
)),
'group_user_ids'
:
group_user_ids
,
'icon'
:
request
.
POST
.
get
(
'icon'
,
''
)[:
-
2
]
}
try
:
self
.
rpc
[
'venus/sun/group/edit'
](
id
=
id
,
data
=
data
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'编辑
%
s用户信息失败
%
s'
%
(
id
,
e
))
raise
return
{
'message'
:
'更新成功'
}
class
GroupRelatedUser
(
APIView
):
def
get
(
self
,
request
):
id
=
request
.
GET
.
get
(
'id'
)
offset
=
int
(
request
.
GET
.
get
(
'page'
,
0
))
count
=
int
(
request
.
GET
.
get
(
'limit'
,
10
))
filters
=
{
'group_id'
:
id
}
try
:
data
=
self
.
rpc
[
'venus/sun/group/user/list'
](
filters
=
filters
,
offset
=
(
offset
-
1
)
*
count
,
limit
=
count
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'获取小组用户信息失败
%
s'
,
e
)
raise
return
data
class
GroupRelatedUserGET
(
APIView
):
def
get
(
self
,
request
):
id
=
request
.
GET
.
get
(
'id'
,
''
)
.
split
(
':'
)[
0
]
try
:
data
=
self
.
rpc
[
'venus/sun/group/user/get'
](
id
=
id
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'获取小组用户信息失败
%
s'
,
e
)
raise
return
[
data
,
]
def
post
(
self
,
request
):
group_id
=
request
.
POST
.
get
(
'group_id'
)
user_id
=
request
.
POST
.
get
(
'user_id'
)
data
=
{
'role_id'
:
request
.
POST
.
get
(
'original_group_identify'
),
}
try
:
self
.
rpc
[
'venus/sun/group/user/edit'
](
id
=
group_id
,
user_id
=
user_id
,
data
=
data
)
.
unwrap
()
except
Exception
as
e
:
error_logger
.
error
(
u'编辑小组用户
%
s信息失败
%
s'
%
(
user_id
,
e
))
raise
return
\ No newline at end of file
api/push.py
View file @
1682a6ae
...
@@ -33,7 +33,7 @@ class PushUpdateOrCreateView(APIView):
...
@@ -33,7 +33,7 @@ class PushUpdateOrCreateView(APIView):
def
post
(
self
,
request
):
def
post
(
self
,
request
):
id
=
request
.
POST
.
get
(
'id'
,
''
)
id
=
request
.
POST
.
get
(
'id'
,
''
)
creator_id
=
request
.
POST
.
get
(
'creator_id'
)
creator_id
=
request
.
POST
.
get
(
'creator_id'
)
group_topic_id
=
request
.
POST
.
get
(
'group
_topic_id'
,
''
)
pictorial_topic_id
=
request
.
POST
.
get
(
'pictorial
_topic_id'
,
''
)
icon
=
request
.
POST
.
get
(
'icon'
,
''
)
icon
=
request
.
POST
.
get
(
'icon'
,
''
)
if
icon
.
endswith
(
'-w'
):
if
icon
.
endswith
(
'-w'
):
icon
=
request
.
POST
.
get
(
'icon'
,
''
)[:
-
2
]
icon
=
request
.
POST
.
get
(
'icon'
,
''
)[:
-
2
]
...
@@ -42,8 +42,8 @@ class PushUpdateOrCreateView(APIView):
...
@@ -42,8 +42,8 @@ class PushUpdateOrCreateView(APIView):
if
url
==
'推送帖子'
:
if
url
==
'推送帖子'
:
url
=
'alpha://topic_detail?topic_id='
url
=
'alpha://topic_detail?topic_id='
elif
url
==
'推送小组'
:
elif
url
==
'推送小组'
:
url
=
'alpha://
group_detail?group
_id='
url
=
'alpha://
pictorial_detail?pictorial
_id='
full_url
=
url
+
group
_topic_id
full_url
=
url
+
pictorial
_topic_id
data
=
{
data
=
{
'url'
:
full_url
,
'url'
:
full_url
,
...
...
api/search.py
View file @
1682a6ae
...
@@ -6,19 +6,6 @@
...
@@ -6,19 +6,6 @@
from
utils.base
import
APIView
,
get_offset_count
from
utils.base
import
APIView
,
get_offset_count
class
GroupSearchView
(
APIView
):
def
get
(
self
,
request
):
name
=
request
.
GET
.
get
(
'name'
)
try
:
data
=
self
.
rpc
[
'venus/sun/group/search'
](
name
=
name
)
.
unwrap
()
except
Exception
as
e
:
raise
e
return
{
'data'
:
[
'{id}:{name}'
.
format
(
id
=
search_data
[
'id'
],
name
=
search_data
[
'name'
])
for
search_data
in
data
]
}
class
CountrySearchView
(
APIView
):
class
CountrySearchView
(
APIView
):
def
get
(
self
,
request
):
def
get
(
self
,
request
):
name
=
request
.
GET
.
get
(
'name'
)
name
=
request
.
GET
.
get
(
'name'
)
...
...
api/star.py
View file @
1682a6ae
...
@@ -47,7 +47,7 @@ class CelebrityUpdateOrCreate(APIView):
...
@@ -47,7 +47,7 @@ class CelebrityUpdateOrCreate(APIView):
def
post
(
self
,
request
):
def
post
(
self
,
request
):
id
=
request
.
POST
.
get
(
'id'
,
''
)
id
=
request
.
POST
.
get
(
'id'
,
''
)
gender
=
request
.
POST
.
get
(
'gender'
)
gender
=
request
.
POST
.
get
(
'gender'
)
group_ids
=
list
(
set
(
map
(
lambda
x
:
x
.
split
(
":"
)[
0
],
json
.
loads
(
request
.
POST
.
get
(
'group
s'
,
'[]'
)))))
pictorial_ids
=
list
(
set
(
map
(
lambda
x
:
x
.
split
(
":"
)[
0
],
json
.
loads
(
request
.
POST
.
get
(
'pictorial
s'
,
'[]'
)))))
updates
=
{
updates
=
{
'gender'
:
''
'gender'
:
''
}
}
...
@@ -66,7 +66,7 @@ class CelebrityUpdateOrCreate(APIView):
...
@@ -66,7 +66,7 @@ class CelebrityUpdateOrCreate(APIView):
'is_online'
:
int
(
request
.
POST
.
get
(
'is_online'
)),
'is_online'
:
int
(
request
.
POST
.
get
(
'is_online'
)),
'desc'
:
request
.
POST
.
get
(
'description'
),
'desc'
:
request
.
POST
.
get
(
'description'
),
'portrait'
:
request
.
POST
.
get
(
'avatar'
)[:
-
2
],
'portrait'
:
request
.
POST
.
get
(
'avatar'
)[:
-
2
],
'
group_ids'
:
group
_ids
,
'
pictorial_ids'
:
pictorial
_ids
,
}
}
try
:
try
:
self
.
rpc
[
'venus/sun/celebrity/edit'
](
id
=
id
,
data
=
data
)
.
unwrap
()
self
.
rpc
[
'venus/sun/celebrity/edit'
](
id
=
id
,
data
=
data
)
.
unwrap
()
...
...
api/urls.py
View file @
1682a6ae
...
@@ -8,7 +8,6 @@ from django.conf.urls import url
...
@@ -8,7 +8,6 @@ from django.conf.urls import url
from
.pick
import
*
from
.pick
import
*
from
.push
import
*
from
.push
import
*
from
.group
import
*
from
.user
import
*
from
.user
import
*
from
.topic
import
*
from
.topic
import
*
from
.star
import
*
from
.star
import
*
...
@@ -34,24 +33,16 @@ urlpatterns = [
...
@@ -34,24 +33,16 @@ urlpatterns = [
url
(
r'^account/list/update$'
,
AccountList
.
as_view
()),
url
(
r'^account/list/update$'
,
AccountList
.
as_view
()),
url
(
r'^account/detail$'
,
AccountUpdateOrCreateView
.
as_view
()),
url
(
r'^account/detail$'
,
AccountUpdateOrCreateView
.
as_view
()),
url
(
r'^account/create$'
,
AccountUpdateOrCreateView
.
as_view
()),
url
(
r'^account/create$'
,
AccountUpdateOrCreateView
.
as_view
()),
# user相关
# user相关
url
(
r'^user/list$'
,
UserListView
.
as_view
()),
url
(
r'^user/list$'
,
UserListView
.
as_view
()),
url
(
r'^user/list/update$'
,
UserListView
.
as_view
()),
url
(
r'^user/list/update$'
,
UserListView
.
as_view
()),
url
(
r'^user/get$'
,
UserUpdateOrCreate
.
as_view
()),
url
(
r'^user/get$'
,
UserUpdateOrCreate
.
as_view
()),
url
(
r'^user/create$'
,
UserUpdateOrCreate
.
as_view
()),
url
(
r'^user/create$'
,
UserUpdateOrCreate
.
as_view
()),
url
(
r'^user/
group/list$'
,
UserGroup
View
.
as_view
()),
url
(
r'^user/
pictorial/list$'
,
UserPictorial
View
.
as_view
()),
url
(
r'^user/images/get$'
,
UserImage
.
as_view
()),
url
(
r'^user/images/get$'
,
UserImage
.
as_view
()),
url
(
r'^user/images/create$'
,
UserImage
.
as_view
()),
url
(
r'^user/images/create$'
,
UserImage
.
as_view
()),
# group相关
url
(
r'^group/list$'
,
GroupListView
.
as_view
()),
url
(
r'^group/list/update$'
,
GroupListView
.
as_view
()),
url
(
r'^group/get$'
,
GroupUpdateOrCreate
.
as_view
()),
url
(
r'^group/create$'
,
GroupUpdateOrCreate
.
as_view
()),
url
(
r'^group/user/list$'
,
GroupRelatedUser
.
as_view
()),
url
(
r'^group/user/get$'
,
GroupRelatedUserGET
.
as_view
()),
url
(
r'^group/user/edit_group_identify'
,
GroupRelatedUserGET
.
as_view
()),
# topic相关
# topic相关
url
(
r'^topic/list$'
,
TopicListView
.
as_view
()),
url
(
r'^topic/list$'
,
TopicListView
.
as_view
()),
url
(
r'^topic/img/list$'
,
TopicImageListView
.
as_view
()),
url
(
r'^topic/img/list$'
,
TopicImageListView
.
as_view
()),
...
@@ -140,7 +131,6 @@ urlpatterns = [
...
@@ -140,7 +131,6 @@ urlpatterns = [
]
]
search_urlpatterns
=
[
search_urlpatterns
=
[
url
(
r'search/group$'
,
GroupSearchView
.
as_view
()),
url
(
r'search/country$'
,
CountrySearchView
.
as_view
()),
url
(
r'search/country$'
,
CountrySearchView
.
as_view
()),
url
(
r'search/user$'
,
UserSearchView
.
as_view
()),
url
(
r'search/user$'
,
UserSearchView
.
as_view
()),
url
(
r'search/tag$'
,
TagSearchView
.
as_view
()),
url
(
r'search/tag$'
,
TagSearchView
.
as_view
()),
...
...
api/user.py
View file @
1682a6ae
...
@@ -18,12 +18,12 @@ from utils.pic_tools import tailor_image
...
@@ -18,12 +18,12 @@ from utils.pic_tools import tailor_image
class
UserListView
(
APIView
):
class
UserListView
(
APIView
):
def
get
(
self
,
request
):
def
get
(
self
,
request
):
group_id
=
request
.
GET
.
get
(
'group
_id'
,
''
)
pictorial_id
=
request
.
GET
.
get
(
'pictorial
_id'
,
''
)
page
=
int
(
request
.
GET
.
get
(
'page'
,
1
))
page
=
int
(
request
.
GET
.
get
(
'page'
,
1
))
limit
=
int
(
request
.
GET
.
get
(
'limit'
,
10
))
limit
=
int
(
request
.
GET
.
get
(
'limit'
,
10
))
filter
=
self
.
handle_filter
(
request
.
GET
.
get
(
'filter'
,
""
))
filter
=
self
.
handle_filter
(
request
.
GET
.
get
(
'filter'
,
""
))
if
group
_id
:
if
pictorial
_id
:
filter
.
update
({
'
group_id'
:
group
_id
})
filter
.
update
({
'
pictorial_id'
:
pictorial
_id
})
try
:
try
:
data
=
self
.
rpc
[
'venus/sun/user/list'
](
offset
=
(
page
-
1
)
*
limit
,
limit
=
limit
,
filters
=
filter
)
.
unwrap
()
data
=
self
.
rpc
[
'venus/sun/user/list'
](
offset
=
(
page
-
1
)
*
limit
,
limit
=
limit
,
filters
=
filter
)
.
unwrap
()
except
Exception
as
e
:
except
Exception
as
e
:
...
@@ -85,16 +85,16 @@ class UserUpdateOrCreate(APIView):
...
@@ -85,16 +85,16 @@ class UserUpdateOrCreate(APIView):
}
}
class
User
Group
View
(
APIView
):
class
User
Pictorial
View
(
APIView
):
def
get
(
self
,
request
):
def
get
(
self
,
request
):
user_id
=
request
.
GET
.
get
(
'id'
)
user_id
=
request
.
GET
.
get
(
'id'
)
offset
=
int
(
request
.
GET
.
get
(
'page'
,
0
))
offset
=
int
(
request
.
GET
.
get
(
'page'
,
0
))
count
=
int
(
request
.
GET
.
get
(
'limit'
,
10
))
count
=
int
(
request
.
GET
.
get
(
'limit'
,
10
))
filters
=
{
'user_id'
:
user_id
}
filters
=
{
'user_id'
:
user_id
}
try
:
try
:
data
=
self
.
rpc
[
'venus/sun/
group
/user/list'
](
filters
=
filters
,
offset
=
(
offset
-
1
)
*
count
,
limit
=
count
)
.
unwrap
()
data
=
self
.
rpc
[
'venus/sun/
pictorial
/user/list'
](
filters
=
filters
,
offset
=
(
offset
-
1
)
*
count
,
limit
=
count
)
.
unwrap
()
except
Exception
as
e
:
except
Exception
as
e
:
error_logger
.
error
(
u'获取
小组
用户详情失败
%
s'
,
e
)
error_logger
.
error
(
u'获取
画报
用户详情失败
%
s'
,
e
)
raise
raise
return
data
return
data
...
...
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