Commit 5a281bfc authored by wangpeng's avatar wangpeng

Merge branch 'master' of git.wanmeizhensuo.com:alpha/sun into feature_docker

parents c151c89a be60d3fd
...@@ -80,7 +80,7 @@ class PictorialActivityListView(APIView): ...@@ -80,7 +80,7 @@ class PictorialActivityListView(APIView):
def get(self, request): def get(self, request):
name = request.GET.get('name') name = request.GET.get('name', '')
page = int(request.GET.get('page', 1)) page = int(request.GET.get('page', 1))
count = int(request.GET.get('count', 10)) count = int(request.GET.get('count', 10))
...@@ -107,12 +107,12 @@ class PictorialActivityView(APIView): ...@@ -107,12 +107,12 @@ class PictorialActivityView(APIView):
data = { data = {
"id": request.POST.get('id'), "id": request.POST.get('id'),
"name": request.POST.get('name', None), "name": request.POST.get('name', ''),
"start_time": request.POST.get('start_time'), "start_time": request.POST.get('start_time'),
"end_time": request.POST.get('end_time'), "end_time": request.POST.get('end_time'),
"version": request.POST.get('version', '0.0.0'), "version": request.POST.get('version', '0.0.0'),
"banner": request.POST.get('banner'), "banner": request.POST.get('banner', ''),
"description": request.POST.get('description'), "description": request.POST.get('description',''),
"titles": json.loads(request.POST.get('titles', '[]')) "titles": json.loads(request.POST.get('titles', '[]'))
} }
......
...@@ -64,6 +64,7 @@ class PictorialUpdateOrCreate(APIView): ...@@ -64,6 +64,7 @@ class PictorialUpdateOrCreate(APIView):
'is_home_recommend': int(request.POST.get('is_home_recommend', 0)), 'is_home_recommend': int(request.POST.get('is_home_recommend', 0)),
'add_score': int(request.POST.get('add_score', 0)), 'add_score': int(request.POST.get('add_score', 0)),
'is_public': True if request.POST.get('is_public') == "true" else False, '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)), 'is_feed': int(request.POST.get('is_feed', 0)),
'pictorial_activity_ids': [int(pictorial_activity_id)] if pictorial_activity_id else [], 'pictorial_activity_ids': [int(pictorial_activity_id)] if pictorial_activity_id else [],
'alias': request.POST.get('alias', ''), 'alias': request.POST.get('alias', ''),
...@@ -147,3 +148,52 @@ class PictorialFeedDelete(APIView): ...@@ -147,3 +148,52 @@ class PictorialFeedDelete(APIView):
return { return {
'message': '删除成功' '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': '删除成功'
}
from datetime import datetime
import json
from utils.base import APIView
from utils.logger import error_logger
from alpha_types.venus import REPLY_TYPE, REPLY_BELONG_TYPE, USER_EXTRA_TYPE
class ReplyUpdateOrCreateView(APIView):
def get(self, request):
topic_id = request.GET.get('topic_id')
pictorial_id = request.GET.get('pictorial_id')
offset = int(request.GET.get('page', 0))
limit = int(request.GET.get('limit', 10))
filter = self.handle_filter(request.GET.get('filter', ""))
if topic_id:
filter.update({'topic_id': topic_id})
elif pictorial_id:
filter.update({'pictorial_id': pictorial_id})
try:
data = self.rpc['venus/sun/reply/list'](offset=(offset-1) * limit, limit=limit, filters=filter).unwrap()
except Exception as e:
error_logger.error(u'回复帖子失败%s' , e)
raise
return data
def post(self, request):
reply_ids = json.loads(request.POST.get('reply_ids', []))
try:
self.rpc['venus/sun/reply/batch_delete'](ids=reply_ids).unwrap()
except Exception as e:
error_logger.error(u'批量更新回复失败%s', e)
raise
return {
'message': '操作成功'
}
class ReplyCreate(APIView):
def post(self, request):
request.POST.get('be_replied_id', None)
data = {
'user_id': request.POST.get('user_id').split(':')[0],
'replied_id': request.POST.get("replied_id", None),
'content': request.POST.get('content'),
'replied_user_id': request.POST.get('replied_user_id', None)
}
topic_id = request.POST.get('topic_id')
pictorial_id = request.POST.get('pictorial_id')
if topic_id:
data['topic_id'] = topic_id
if pictorial_id:
data['pictorial_id'] = pictorial_id
try:
data = self.rpc['venus/sun/reply/edit'](id=None, data=data).unwrap()
except Exception as e:
error_logger.error(u'编辑评论失败%s', e)
raise
return {'data': data}
class ReplyVote(APIView):
def post(self, request):
reply_id = int(request.POST.get('reply_id'))
vote_num = int(request.POST.get('vote_num'))
try:
self.rpc['venus/sun/reply/vote'](reply_id=reply_id, vote_num=vote_num).unwrap()
except Exception as e:
error_logger.error(u'编辑帖子失败%s', e)
raise
return {
'message': '操作成功'
}
class ReplyManageListView(APIView):
def get(self, request):
page = int(request.GET.get('page', 1))
limit = int(request.GET.get('limit', 10))
topic_id = request.GET.get('topic_id', None)
content = request.GET.get('content', None)
topic_content = request.GET.get('topic_content', None)
user_name = request.GET.get('user_name', None)
belong_type = request.GET.get('belong_type', None)
reply_level = request.GET.get('reply_level', None)
reply_user_type = request.GET.get('reply_user_type', None)
replied_user_type = request.GET.get('replied_user_type', None)
is_online = request.GET.get('is_online', None)
from_create_time = request.GET.get('from_create_time', None)
to_create_time = request.GET.get('to_create_time', None)
from_topic_create_time = request.GET.get('from_topic_create_time', None)
to_topic_create_time = request.GET.get('to_topic_create_time', None)
other_filters = {}
if topic_content:
other_filters['topic_content'] = topic_content
if reply_user_type:
reply_user_type = int(reply_user_type)
if reply_user_type in [USER_EXTRA_TYPE.REAL, USER_EXTRA_TYPE.SHADOW, USER_EXTRA_TYPE.KOL]:
other_filters['reply_user_type'] = reply_user_type
if replied_user_type:
replied_user_type = int(replied_user_type)
if replied_user_type in [USER_EXTRA_TYPE.REAL, USER_EXTRA_TYPE.SHADOW, USER_EXTRA_TYPE.KOL]:
other_filters['replied_user_type'] = replied_user_type
if from_topic_create_time and to_topic_create_time:
other_filters['topic_create_time__gte'] = from_topic_create_time
other_filters['topic_create_time__lte'] = to_topic_create_time
if user_name:
other_filters['user_name'] = user_name
filters = {}
if topic_id:
filters['topic_id'] = int(topic_id)
if content:
filters['content__contains'] = content
if belong_type:
if belong_type in REPLY_BELONG_TYPE:
filters['belong_type'] = belong_type
if reply_level:
reply_level = int(reply_level)
if reply_level == 1:
filters['top_id__lte'] = 0
if reply_level == 2:
filters['top_id__gt'] = 0
if is_online:
is_online = int(is_online)
filters['is_online'] = is_online
if from_create_time and to_create_time:
filters['create_time__gte'] = from_create_time
filters['create_time__lte'] = to_create_time
try:
data = self.rpc['venus/sun/reply/manage/list'](offset=(page-1) * limit, limit=limit, filters=filters, other_filters=other_filters).unwrap()
except Exception as e:
error_logger.error(u'获取reply列表失败%s', e)
raise
return data
class ReplyManageCreateView(APIView):
def post(self, request):
id_ = request.POST.get('id', None)
replied_id = request.POST.get('replied_id')
topic_id = request.POST.get('topic_id')
pictorial_id = request.POST.get('pictorial_id')
user_id = request.POST.get('user_id')
content = request.POST.get('content')
data = {
'replied_id': replied_id,
'topic_id': topic_id if topic_id else 0,
'pictorial_id': pictorial_id if pictorial_id else 0,
'user_id': user_id,
'content': content,
'type': REPLY_TYPE.PUPPET_REPLY_ANS,
}
try:
rep = self.rpc['venus/sun/reply/manage/edit'](id_=id_, data=data).unwrap()
except Exception as e:
error_logger.error(u'创建/编辑%s-reply信息失败%s' % (id, e))
raise
return {
"message": '更新成功',
"id": rep['id']
}
class ReplyManageBatchUpdate(APIView):
def post(self, request):
ids = json.loads(request.POST.get('ids', '[]'))
is_online = request.POST.get('is_online', None)
try:
rep = self.rpc['venus/sun/reply/manage/batch/update'](ids=ids, is_online=is_online).unwrap()
except Exception as e:
error_logger.error(u'更新-reply信息失败%s' % (e))
raise
return {
"message": '更新成功',
}
class ReplyManageBatchMove(APIView):
def post(self, request):
ids = json.loads(request.POST.get('ids', '[]'))
topic_id = request.POST.get('topic_id', None)
pictorial_id = request.POST.get('pictorial_id', None)
try:
self.rpc['venus/sun/reply/manage/batch/move'](ids=ids, topic_id=topic_id, pictorial_id=pictorial_id).unwrap()
except Exception as e:
error_logger.error(u'平移reply失败%s' % (e))
raise
return {
"message": '更新成功',
}
class ReplyManageEdit(APIView):
def post(self, request):
id_ = request.POST.get('id')
content = request.POST.get('content')
try:
self.rpc['venus/sun/reply/manage/edit'](id_=id_, data={'content': content}).unwrap()
except Exception as e:
error_logger.error(u'平移reply失败%s' % (e))
raise
return {
"message": '更新成功',
}
...@@ -157,50 +157,6 @@ class TopicUpdateOrCreateView(APIView): ...@@ -157,50 +157,6 @@ class TopicUpdateOrCreateView(APIView):
} }
class ReplyUpdateOrCreateView(APIView):
def get(self, request):
id = request.GET.get('id')
offset = int(request.GET.get('page', 0))
limit = int(request.GET.get('limit', 10))
filter = self.handle_filter(request.GET.get('filter', ""))
filter.update({'topic_id': id})
try:
data = self.rpc['venus/sun/topic/reply/list'](offset=(offset-1) * limit, limit=limit, filters=filter).unwrap()
except Exception as e:
error_logger.error(u'回复帖子失败%s' , e)
raise
return data
def post(self, request):
reply_ids = json.loads(request.POST.get('reply_ids', []))
try:
self.rpc['venus/sun/topic/reply/batch_delete'](ids=reply_ids).unwrap()
except Exception as e:
error_logger.error(u'批量更新帖子失败%s', e)
raise
return {
'message': '操作成功'
}
class ReplyCreate(APIView):
def post(self, request):
request.POST.get('be_replied_id', None)
data = {
'user_id': request.POST.get('user_id').split(':')[0],
'replied_id': request.POST.get("replied_id", None),
'topic_id': request.POST.get("topic_id", None),
'content': request.POST.get('content'),
'replied_user_id': request.POST.get('replied_user_id', None)
}
try:
data = self.rpc['venus/sun/topic/reply/edit'](id=None, data=data).unwrap()
except Exception as e:
error_logger.error(u'编辑帖子失败%s', e)
raise
return {'data': data}
class TopicListBatchUpdate(APIView): class TopicListBatchUpdate(APIView):
def post(self, request): def post(self, request):
......
...@@ -31,6 +31,7 @@ from .product import * ...@@ -31,6 +31,7 @@ from .product import *
from .category import * from .category import *
from .classify import * from .classify import *
from .effect import * from .effect import *
from .reply import *
urlpatterns = [ urlpatterns = [
...@@ -59,9 +60,6 @@ urlpatterns = [ ...@@ -59,9 +60,6 @@ urlpatterns = [
url(r'^topic/detail$', TopicUpdateOrCreateView.as_view()), url(r'^topic/detail$', TopicUpdateOrCreateView.as_view()),
url(r'^topic/create$', TopicUpdateOrCreateView.as_view()), url(r'^topic/create$', TopicUpdateOrCreateView.as_view()),
url(r'^topic/batch_update$', TopicListBatchUpdate.as_view()), url(r'^topic/batch_update$', TopicListBatchUpdate.as_view()),
url(r'^topic/reply/list$', ReplyUpdateOrCreateView.as_view()),
url(r'^topic/reply/batch_delete$', ReplyUpdateOrCreateView.as_view()),
url(r'^topic/reply/create$', ReplyCreate.as_view()),
url(r'^topic/related_pictorial_info$', TopicRelatePictorialInfo.as_view()), url(r'^topic/related_pictorial_info$', TopicRelatePictorialInfo.as_view()),
url(r'^topic/ballot$', TopicBallot.as_view()), url(r'^topic/ballot$', TopicBallot.as_view()),
url(r'^topic/product/add$', TopicProductAdd.as_view()), url(r'^topic/product/add$', TopicProductAdd.as_view()),
...@@ -143,6 +141,8 @@ urlpatterns = [ ...@@ -143,6 +141,8 @@ urlpatterns = [
url(r'^suggestion/list$', SuggestionListView.as_view()), url(r'^suggestion/list$', SuggestionListView.as_view()),
# 画报相关 # 画报相关
url(r'^pictorial/topic/set_rank$', PictorialTopicSetRank.as_view()),
url(r'^pictorial/topic/del$', PictorialTopicDel.as_view()),
url(r'^pictorial/list$', PictorialListView.as_view()), url(r'^pictorial/list$', PictorialListView.as_view()),
url(r'^pictorial/list/update$', PictorialListView.as_view()), url(r'^pictorial/list/update$', PictorialListView.as_view()),
url(r'^pictorial/get$', PictorialUpdateOrCreate.as_view()), url(r'^pictorial/get$', PictorialUpdateOrCreate.as_view()),
...@@ -152,6 +152,7 @@ urlpatterns = [ ...@@ -152,6 +152,7 @@ urlpatterns = [
url(r'^pictorial/feed/list$', PictorialFeedlListView.as_view()), url(r'^pictorial/feed/list$', PictorialFeedlListView.as_view()),
url(r'^pictorial/feed/rank$', PictorialFeedlRank.as_view()), url(r'^pictorial/feed/rank$', PictorialFeedlRank.as_view()),
url(r'^pictorial/feed/delete$', PictorialFeedDelete.as_view()), url(r'^pictorial/feed/delete$', PictorialFeedDelete.as_view()),
url(r'^pictorial/topic/list$', PictorialTopicList.as_view()),
#运营位 #运营位
url(r'^topic/home_recommend/list', TopicHomeRecommendList.as_view()), url(r'^topic/home_recommend/list', TopicHomeRecommendList.as_view()),
...@@ -215,7 +216,19 @@ urlpatterns = [ ...@@ -215,7 +216,19 @@ urlpatterns = [
# 商品功效 # 商品功效
url(r'^effect/list$', EffectListView.as_view()), url(r'^effect/list$', EffectListView.as_view()),
#评论相关
url(r'^reply/list$', ReplyUpdateOrCreateView.as_view()),
url(r'^reply/batch_delete$', ReplyUpdateOrCreateView.as_view()),
url(r'^reply/create$', ReplyCreate.as_view()),
url(r'^reply/vote$', ReplyVote.as_view()),
# 评论管理
url(r'^reply/manage/edit$', ReplyManageEdit.as_view()),
url(r'^reply/manage/batch/move$', ReplyManageBatchMove.as_view()),
url(r'^reply/manage/list$', ReplyManageListView.as_view()),
url(r'^reply/manage/create$', ReplyManageCreateView.as_view()),
url(r'^reply/manage/batch/update$', ReplyManageBatchUpdate.as_view()),
] ]
search_urlpatterns = [ search_urlpatterns = [
......
...@@ -80,6 +80,7 @@ class UserUpdateOrCreate(APIView): ...@@ -80,6 +80,7 @@ class UserUpdateOrCreate(APIView):
'gender': request.POST.get('gender'), 'gender': request.POST.get('gender'),
'is_tcc': int(request.POST.get('is_tcc', 0)), 'is_tcc': int(request.POST.get('is_tcc', 0)),
'body_esthetics_tag_ids': body_esthetics_tag_ids, 'body_esthetics_tag_ids': body_esthetics_tag_ids,
'is_kol': int(request.POST.get('is_kol', 0)),
} }
try: try:
...@@ -94,10 +95,10 @@ class UserUpdateOrCreate(APIView): ...@@ -94,10 +95,10 @@ class UserUpdateOrCreate(APIView):
class PictorialUserList(APIView): class PictorialUserList(APIView):
def get(self, request): def get(self, request):
id_ = request.GET.get('id') id_ = request.GET.get('pictorial_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 = {'pictorial_id': id_} filters = {'pictorial_id': id_, 'is_online': True}
try: try:
data = self.rpc['venus/sun/pictorial/user/list'](filters=filters, offset=(offset - 1) * count, count=count).unwrap() data = self.rpc['venus/sun/pictorial/user/list'](filters=filters, offset=(offset - 1) * count, count=count).unwrap()
except Exception as e: except Exception as e:
......
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