1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
import json
from utils.base import APIView
from utils.logger import error_logger
class PictorialListView(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', 1))
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/pictorial/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('update', '{}'))
try:
self.rpc['venus/sun/pictorial/batch/update'](updates=updates, ids=ids).unwrap()
except Exception as e:
error_logger.error(u'批量更新失败%s', e)
raise
return {
"message": "更新成功"
}
class PictorialUpdateOrCreate(APIView):
def get(self, request):
id = request.GET.get('id').split(':')[0]
try:
data = self.rpc['venus/sun/pictorial/get'](id=id).unwrap()
except Exception as e:
error_logger.error(u'获取%s画报信息失败%s'%(id, e))
raise
return data
def post(self, request):
id = int(request.POST.get('id')) if request.POST.get('id') else None
star_ids = json.loads(request.POST.get('star', '[]'))
pictorial_user_ids = json.loads(request.POST.get('pictorial_user_ids', '[]'))
collection_tag_ids = json.loads(request.POST.get('collection_tag_ids', '[]'))
pictorial_activity_id = request.POST.get('pictorial_activity_id')
tab_config = request.POST.get("tab_config")
if tab_config:
tab_config = []
data = {
'name': request.POST.get('name', ''),
'description': request.POST.get('description', ''),
'creator_id': request.POST.get('creator_id', ''),
'celebrity_ids': star_ids,
'is_online': int(request.POST.get('is_online', 1)),
'is_recommend': int(request.POST.get('is_recommend', 0)),
'pictorial_user_ids': pictorial_user_ids,
'icon': request.POST.get('icon', ''),
'collection_tag_ids': collection_tag_ids,
'is_home_recommend': int(request.POST.get('is_home_recommend', 0)),
'add_score': int(request.POST.get('add_score', 0)),
'is_public': True if request.POST.get('is_public') == "true" else False,
'is_finished': int(request.POST.get('is_finished', 1)),
'is_feed': int(request.POST.get('is_feed', 0)),
'pictorial_activity_ids': [int(pictorial_activity_id)] if pictorial_activity_id else [],
'alias': request.POST.get('alias', ''),
'comment_talk': request.POST.get('pictorial_comment_talk', ''),
'tab_config': json.loads(tab_config),
}
try:
data = self.rpc['venus/sun/pictorial/edit'](id=id, data=data).unwrap()
except Exception as e:
error_logger.error(u'编辑%s用户信息失败%s' % (id, e))
raise
if not data.get('id'):
return {
'message': '画报已存在'
}
return {
'message': '更新成功',
'data': data
}
class PictorialTopics(APIView):
"""多个帖子关系"""
def post(self, request):
topic_ids = json.loads(request.POST.get('topic_ids', '[]'))
pictorial_id = request.POST.get('pictorial_id')
try:
self.rpc['venus/sun/pictorial/add_topics'](topic_ids=topic_ids, pictorial_id=pictorial_id).unwrap()
except Exception as e:
error_logger.error(u'编辑%s用户信息失败%s' % (id, e))
raise
return {
'message': '更新成功'
}
class PictorialFeedlListView(APIView):
def get(self, request):
order_by = request.GET.get('order_by', "-id")
offset = int(request.GET.get('offset', 1))
limit = int(request.GET.get('limit', 10))
try:
data = self.rpc['venus/sun/pictorial/feed/list'](offset=(offset - 1) * limit, limit=limit,
order_by=order_by).unwrap()
except Exception as e:
error_logger.error(u'获取画报列表失败%s' , e)
raise
return data
class PictorialFeedlRank(APIView):
"""修改画报首页like流rank"""
def post(self, request):
id_ = request.POST.get('id')
rank = int(request.POST.get('rank'))
try:
self.rpc['venus/sun/pictorial/feed/rank'](id_=id_, rank=rank).unwrap()
except Exception as e:
error_logger.error(u'编辑%信息失败%s' % (e))
raise
return {
'message': '更新成功'
}
class PictorialFeedDelete(APIView):
"""删除画报首页like流"""
def post(self, request):
ids = json.loads(request.POST.get('ids', '[]'))
try:
self.rpc['venus/sun/pictorial/feed/delete'](ids=ids).unwrap()
except Exception as e:
error_logger.error(u'删除信息失败%s' % (e))
raise
return {
'message': '删除成功'
}
class PictorialTopicList(APIView):
"""获取榜单帖子列表"""
def get(self, request):
id_ = request.GET.get('id')
offset = int(request.GET.get('page', 1))
limit = int(request.GET.get('count', 10))
try:
data = self.rpc['venus/sun/pictorial/topic/list'](id_=id_, offset=(offset-1)*limit, limit=limit).unwrap()
except Exception as e:
error_logger.error(u'获取信息失败%s' % (e))
raise
return data
class PictorialTopicSetRank(APIView):
"""设置榜单中帖子的优先级"""
def post(self, request):
pictorial_id = request.POST.get('pictorial_id')
topic_id = request.POST.get('topic_id')
rank = request.POST.get('rank')
try:
self.rpc['venus/sun/pictorial/topic/set_rank'](pictorial_id=pictorial_id, topic_id=topic_id, rank=rank).unwrap()
except Exception as e:
error_logger.error(u'操作失败%s' % (e))
raise
return {
'message': '操作成功'
}
class PictorialTopicDel(APIView):
"""删除榜单中的帖子"""
def post(self, request):
pictorial_id = request.POST.get('pictorial_id')
topic_id = request.POST.get('topic_id')
try:
self.rpc['venus/sun/pictorial/topic/del'](pictorial_id=pictorial_id, topic_id=topic_id).unwrap()
except Exception as e:
error_logger.error(u'操作失败%s' % (e))
raise
return {
'message': '删除成功'
}