Commit 0c6dda63 authored by 王浩's avatar 王浩

Merge branch 'test' into 'haow/dev'

# Conflicts:
#   api/reply.py
#   api/urls.py
parents 0b99b3b6 366981c5
...@@ -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', '[]'))
} }
......
...@@ -5,7 +5,84 @@ from utils.logger import error_logger ...@@ -5,7 +5,84 @@ from utils.logger import error_logger
from alpha_types.venus import REPLY_TYPE, REPLY_BELONG_TYPE, USER_EXTRA_TYPE from alpha_types.venus import REPLY_TYPE, REPLY_BELONG_TYPE, USER_EXTRA_TYPE
class ReplyListView(APIView): 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): def get(self, request):
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))
...@@ -22,7 +99,7 @@ class ReplyListView(APIView): ...@@ -22,7 +99,7 @@ class ReplyListView(APIView):
to_create_time = request.GET.get('to_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) from_topic_create_time = request.GET.get('from_topic_create_time', None)
to_topic_create_time = request.GET.get('to_topic_create_time', None) to_topic_create_time = request.GET.get('to_topic_create_time', None)
other_filters = {} other_filters = {}
if topic_content: if topic_content:
other_filters['topic_content'] = topic_content other_filters['topic_content'] = topic_content
...@@ -68,7 +145,7 @@ class ReplyListView(APIView): ...@@ -68,7 +145,7 @@ class ReplyListView(APIView):
return data return data
class ReplyCreateView(APIView): class ReplyManageCreateView(APIView):
def post(self, request): def post(self, request):
id_ = request.POST.get('id', None) id_ = request.POST.get('id', None)
......
...@@ -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):
......
...@@ -60,9 +60,6 @@ urlpatterns = [ ...@@ -60,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()),
...@@ -217,6 +214,12 @@ urlpatterns = [ ...@@ -217,6 +214,12 @@ 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/list$', ReplyListView.as_view()), url(r'^reply/manage/list$', ReplyListView.as_view()),
url(r'^reply/manage/create$', ReplyCreateView.as_view()), url(r'^reply/manage/create$', ReplyCreateView.as_view()),
......
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