Commit 2b955c24 authored by 杨成林's avatar 杨成林

Merge branch 'ycl/pictorial_activity' into 'dev'

ycl/pictorial_activity

See merge request alpha/sun!236
parents 7932a59d 77bab0cc
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 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):
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,9 @@ 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/get', PictorialActivityInfoView.as_view()),
url(r'^activity/pictorial', PictorialActivityView.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