Commit 77bab0cc authored by yangchenglin's avatar yangchenglin

ycl/pictorial_activity

parent ef397482
import json import json
from datetime import datetime
from utils.base import APIView, get_offset_count from utils.base import APIView, get_offset_count
from utils.logger import error_logger
class ActivityListView(APIView): class ActivityListView(APIView):
...@@ -74,3 +74,66 @@ class ActivityDeleteView(APIView): ...@@ -74,3 +74,66 @@ class ActivityDeleteView(APIView):
return r'操作失败' return r'操作失败'
return data return data
class PictorialActivityInfoView(APIView):
def get(self, request):
id_ = int(request.GET.get('id'))
data = self.rpc['venus/sun/activity/pictrial/info'](id_=id_).unwrap()
if not data:
return r'获取失败'
return data
class PictorialActivityView(APIView):
def get(self, request):
name = request.GET.get('name')
page = int(request.GET.get('page', 1))
count = int(request.GET.get('count', 10))
data = self.rpc['venus/sun/activity/pictrial/list'](name=name, offset=(page - 1) * count, count=count).unwrap()
if not data:
return r'获取失败'
return data
def post(self, request):
data = {
"id": request.POST.get('id'),
"name": request.POST.get('name', None),
"start_time": int(request.POST.get('start_time'))/1000,
"end_time": int(request.POST.get('end_time'))/1000,
"version": request.POST.get('version', '0.0.0'),
"banner": request.POST.get('banner'),
"description": request.POST.get('description'),
"titles": json.loads(request.POST.get('titles', '[]'))
}
data = self.rpc['venus/sun/activity/pictrial/edit'](data=data).unwrap()
if not data:
return r'操作失败'
return data
class PictorialActivityOlineView(APIView):
def post(self, request):
id_ = int(request.POST.get('id'))
is_online = int(request.POST.get('is_online'))
data = self.rpc['venus/sun/activity/pictrial/online'](id_=id_, is_online=is_online).unwrap()
if not data:
return r'操作失败'
return data
...@@ -67,12 +67,14 @@ class TopicHomeFixOperation(APIView): ...@@ -67,12 +67,14 @@ class TopicHomeFixOperation(APIView):
image = request.POST.get('image') image = request.POST.get('image')
protocol = request.POST.get("protocol") protocol = request.POST.get("protocol")
pos = request.POST.get("pos", 4) pos = request.POST.get("pos", 4)
version = request.POST.get("version", 4)
if not image or not protocol: if not image or not protocol:
return {'message': '参数不全'} return {'message': '参数不全'}
try: try:
self.rpc['venus/sun/operation/home_fix/edit'](image=image, protocol=protocol, pos=pos).unwrap() self.rpc['venus/sun/operation/home_fix/edit'](image=image, protocol=protocol, pos=pos,
version=version).unwrap()
except Exception as e: except Exception as e:
error_logger.error(u'更新失败', e) error_logger.error(u'更新失败', e)
raise raise
......
...@@ -45,10 +45,12 @@ class PictorialUpdateOrCreate(APIView): ...@@ -45,10 +45,12 @@ class PictorialUpdateOrCreate(APIView):
return data return data
def post(self, request): def post(self, request):
id = request.POST.get('id') id = request.POST.get('id')
star_ids = json.loads(request.POST.get('star', '[]')) star_ids = json.loads(request.POST.get('star', '[]'))
pictorial_user_ids = json.loads(request.POST.get('pictorial_user_ids', '[]')) pictorial_user_ids = json.loads(request.POST.get('pictorial_user_ids', '[]'))
collection_tag_ids = json.loads(request.POST.get('collection_tag_ids', '[]')) collection_tag_ids = json.loads(request.POST.get('collection_tag_ids', '[]'))
pictorial_activity_id = request.POST.get('pictorial_activity_id')
data = { data = {
'name': request.POST.get('name', ''), 'name': request.POST.get('name', ''),
'description': request.POST.get('description', ''), 'description': request.POST.get('description', ''),
...@@ -62,7 +64,8 @@ class PictorialUpdateOrCreate(APIView): ...@@ -62,7 +64,8 @@ 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_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 None]
} }
try: try:
......
...@@ -184,6 +184,9 @@ urlpatterns = [ ...@@ -184,6 +184,9 @@ urlpatterns = [
url(r'^activity/create$', ActivityCreateView.as_view()), url(r'^activity/create$', ActivityCreateView.as_view()),
url(r'^activity/update$', ActivityUpdateView.as_view()), url(r'^activity/update$', ActivityUpdateView.as_view()),
url(r'^activity/delete$', ActivityDeleteView.as_view()), url(r'^activity/delete$', ActivityDeleteView.as_view()),
url(r'^activity/pictorial/get', PictorialActivityInfoView.as_view()),
url(r'^activity/pictorial', PictorialActivityView.as_view()),
url(r'^activity/pictorial/online', PictorialActivityView.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