Commit 958fc338 authored by 王浩's avatar 王浩

Merge branch 'haow/dev' into 'dev'

Haow/dev

See merge request alpha/sun!191
parents 9f0d4c07 266cb0b3
......@@ -75,7 +75,10 @@ class LoginView(APIView):
'avatar': settings.AVATAR
})
if data['is_staff']:
data.update({'roles': ['staff']})
if data.get('staff_level'):
data.update({'roles': ['mbhoperator']})
else:
data.update({'roles': ['staff']})
else:
data.update({'roles': ['anonymous']})
except Exception as e:
......@@ -114,7 +117,10 @@ class LoginView(APIView):
error_logger.error(u'登陆失败%s', e)
raise
if data['is_staff']:
ret.update({'roles': ['staff']})
if data.get('staff_level'):
ret.update({'roles': ['mbhoperator']})
else:
ret.update({'roles': ['staff']})
else:
ret.update({'roles': ['anonymous']})
return {
......
......@@ -61,6 +61,7 @@ class PictorialUpdateOrCreate(APIView):
'collection_tag_ids': collection_tag_ids,
'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
}
try:
......
import time
import json
from utils.base import APIView
from gm_upload import upload, upload_file
from openpyxl import load_workbook
......@@ -71,3 +72,22 @@ class BatchUpdateTopicTag(APIView):
self.rpc['venus/sun/tools/batch_update_topic_tags'](topic_infos=topic_infos).unwrap()
return {'message': u'上传成功', 'code': 200}
class BatchCreateTopicWithAiFashionTag(APIView):
def post(self, request):
json_file = request.FILES.get('file')
tag_infos = request.POST.get('tag_infos', '[]')
if not json_file and not tag_infos:
return {'message': u'上传失败,请重新上传', 'code': 500}
if json_file:
json_data = json.load(json_file)
self.rpc['venus/sun/tools/batch_create_topic_with_ai_fashion_tag'](infos=json_data).unwrap()
if tag_infos:
json_data = json.loads(tag_infos)
self.rpc['venus/sun/tools/batch_create_topic_with_ai_fashion_tag'](infos=json_data).unwrap()
return {'message': u'上传成功', 'code': 200}
......@@ -119,6 +119,7 @@ class TopicUpdateOrCreateView(APIView):
topic_images = list(map(lambda x: x[:-2], json.loads(request.POST.get('topic_images', '[]'))))
tag_ids = list(map(lambda x: x.split(':')[0], json.loads(request.POST.get('tags', '[]'))))
collection_tag_ids = list(map(lambda x: x.split(':')[0], json.loads(request.POST.get('collection_tags', '[]'))))
cut_word_tag_ids = list(map(lambda x: x.split(':')[0], json.loads(request.POST.get('cut_word_tags', '[]'))))
pictorial_ids = list(json.loads(request.POST.get('pictorial_ids', '[]')))
data = {
......@@ -132,6 +133,7 @@ class TopicUpdateOrCreateView(APIView):
'star_id': request.POST.get('star', '').split(':')[0],
'tag_ids': tag_ids,
'collection_tag_ids': collection_tag_ids,
'cut_word_tag_ids': cut_word_tag_ids,
'is_online': int(request.POST.get('is_online', 0)),
'drop_score': int(request.POST.get('drop_score', 0)),
'has_image': 1 if topic_images else 0,
......
......@@ -144,6 +144,7 @@ urlpatterns = [
# 工具
url(r'^tools/virtual_vote$', VirtualVote.as_view()),
url(r'^tools/batch_update_topic_tag$', BatchUpdateTopicTag.as_view()),
url(r'^tools/batch_create_topic_with_ai_fashion_tag$', BatchCreateTopicWithAiFashionTag.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