Commit 06422cb1 authored by 钟尚武's avatar 钟尚武

Merge branch 'test' into 'master'

2.6跟版需求上线

See merge request alpha/sun!395
parents b4f181eb 2196a31c
import json
from utils.base import APIView, get_offset_count
class LaboratoryListView(APIView):
def get(self, request):
offset, count = get_offset_count(request)
data = self.rpc['venus/sun/laboratory/list'](offset=offset, count=count).unwrap()
return data
class LaboratoryView(APIView):
def post(self, request):
laboratory_id = request.POST.get('id', None)
title = request.POST.get("title", "")
order = request.POST.get("order", "")
image_url = request.POST.get("image_url", "")
agreement_url = request.POST.get("agreement_url", "")
description_fomula = request.POST.get("description_fomula", "")
data = self.rpc["venus/sun/laboratory/create"](
title=title,
order=order,
description_fomula=description_fomula,
image_url=image_url,
agreement_url=agreement_url,
laboratory_id=laboratory_id
).unwrap()
return data
class LaboratoryDeleteView(APIView):
def post(self, request):
laboratory_id = request.POST.get('id', None)
data = self.rpc['venus/sun/laboratory/delete'](
laboratory_id=laboratory_id
).unwrap()
return {
"status": 1
}
......@@ -270,6 +270,7 @@ class TagRelatePictorialInfo(APIView):
except Exception as e:
error_logger.error(u'获取画报列表失败%s', e)
raise
return data
......
......@@ -34,6 +34,7 @@ from .effect import *
from .skin_check import *
from .reply import *
from .survey import *
from .laboratory import *
urlpatterns = [
......@@ -55,6 +56,10 @@ urlpatterns = [
url(r'^user/create$', UserUpdateOrCreate.as_view()),
url(r'^user/images/get$', UserImage.as_view()),
url(r'^user/images/create$', UserImage.as_view()),
url(r'^user/kol_pool_list$', KOLPoolList.as_view()),
url(r'^user/kol_pool_rm$', KOLPoolRm.as_view()),
url(r'^user/kol_pool_add$', KOLPoolAdd.as_view()),
url(r'^user/kol_pool_edit$', KOLPoolEdit.as_view()),
# topic相关
url(r'^topic/list$', TopicListView.as_view()),
......@@ -256,6 +261,11 @@ urlpatterns = [
url(r'^survey_question/get$', SurveyView.as_view()),
url(r'^survey_question/list$', SurveyListView.as_view()),
url(r'^survey_question/add_answer$', SurveyAddAnswerView.as_view()),
# 测试频道
url(r'^laboratory/create$', LaboratoryView.as_view()),
url(r'^laboratory/list$', LaboratoryListView.as_view()),
url(r'^laboratory/delete$', LaboratoryDeleteView.as_view()),
]
search_urlpatterns = [
......
......@@ -178,3 +178,72 @@ class UserImage(APIView):
error_logger.error(u'获取%s用户头像失败%s' % (user_id, e))
raise
return data
class KOLPoolList(APIView):
def get(self, request):
page = int(request.GET.get('page', 1))
limit = int(request.GET.get('limit', 50))
try:
res = self.rpc['venus/sun/user/kol_pool_list'](
offset=(page - 1) * limit,
limit=limit,
).unwrap()
except Exception as e:
error_logger.error(u'获取kol池失败%s' % e)
raise
return res
class KOLPoolRm(APIView):
def post(self, request):
user_ids = json.loads(request.POST.get('user_ids', "[]"))
try:
res = self.rpc['venus/sun/user/kol_pool/delete'](
user_ids=user_ids
).unwrap()
except Exception as e:
error_logger.error(u'kol池删除用户失败%s' % e)
raise
return res
class KOLPoolAdd(APIView):
def post(self, request):
user_ids = json.loads(request.POST.get('user_ids', "[]"))
try:
self.rpc['venus/sun/user/kol_pool/add'](
user_ids=user_ids
).unwrap()
except Exception as e:
error_logger.error(u'kol池增加用户失败%s' % e)
raise
class KOLPoolEdit(APIView):
def post(self, request):
data = json.loads(request.POST.get('data', "{}"))
try:
self.rpc['venus/sun/user/kol_pool/edit'](
data=data
).unwrap()
except Exception as e:
error_logger.error(u'kol池编辑用户失败%s' % e)
raise
\ No newline at end of file
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