Commit 3437eb2b authored by 杨成林's avatar 杨成林

Merge branch 'ycl/pictorial_activity' into 'test'

Ycl/pictorial activity

See merge request alpha/sun!238
parents 900e796e dd6ac928
import json
from datetime import datetime
from utils.base import APIView, get_offset_count
from utils.logger import error_logger
class ActivityListView(APIView):
......@@ -74,3 +74,66 @@ class ActivityDeleteView(APIView):
return r'操作失败'
return data
class PictorialActivityListView(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
class PictorialActivityView(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.get("data")
def post(self, request):
data = {
"id": request.POST.get('id'),
"name": request.POST.get('name', None),
"start_time": request.POST.get('start_time'),
"end_time": request.POST.get('end_time'),
"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):
image = request.POST.get('image')
protocol = request.POST.get("protocol")
pos = request.POST.get("pos", 4)
version = request.POST.get("version", 4)
if not image or not protocol:
return {'message': '参数不全'}
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:
error_logger.error(u'更新失败', e)
raise
......
......@@ -46,10 +46,12 @@ class PictorialUpdateOrCreate(APIView):
return data
def post(self, request):
id = request.POST.get('id')
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')
data = {
'name': request.POST.get('name', ''),
'description': request.POST.get('description', ''),
......@@ -63,7 +65,8 @@ class PictorialUpdateOrCreate(APIView):
'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_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:
......
......@@ -192,6 +192,10 @@ urlpatterns = [
url(r'^activity/create$', ActivityCreateView.as_view()),
url(r'^activity/update$', ActivityUpdateView.as_view()),
url(r'^activity/delete$', ActivityDeleteView.as_view()),
url(r'^activity/pictorial', PictorialActivityView.as_view()),
url(r'^activity/pictorial', PictorialActivityView.as_view()),
url(r'^activity/pictorial/list', PictorialActivityListView.as_view()),
url(r'^activity/pictorial/online', PictorialActivityView.as_view()),
# 品牌
url(r'^brand/list$', BrandListView.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