def category_list(request): _group_id = request.GET.get("gid", None) if _group_id != None: _group_id = int(_group_id) _status = request.GET.get("status", None) if _status != None: _status = int(_status) _all_count = len(Category.find(group_id=_group_id)) _normal_count = len(Category.find(group_id=_group_id, status=1)) _freeze_count = _all_count - _normal_count _category_groups = Category.allgroups() _categories = Category.find(group_id=_group_id, status=_status, order_by='-status') for _category in _categories: _category["group_title"] = Category_Group( _category["group_id"]).read()["title"] return render_to_response('category/list.html', { 'active_division': 'category', 'category_groups': _category_groups, 'categories': _categories, 'selected_group_id': _group_id, 'status': _status, 'all_count': _all_count, 'normal_count': _normal_count, 'freeze_count': _freeze_count }, context_instance=RequestContext(request))
def edit_category(request, category_id): if request.method == 'GET': _category_groups = Category.allgroups() _category_context = Category(category_id).read() _category_entity_count = Entity.count(category_id) return render_to_response( 'category/edit.html', { 'active_division': 'category', 'category_groups': _category_groups, 'category_context': _category_context, 'category_entity_count': _category_entity_count }, context_instance=RequestContext(request)) elif request.method == 'POST': _group_id = request.POST.get("group_id", None) _title = request.POST.get("title", None) _status = request.POST.get("status", None) _image_file = request.FILES.get("image_file", None) _image_data = None if _image_file != None: if hasattr(_image_file, 'chunks'): _image_data = ''.join(chunk for chunk in _image_file.chunks()) else: _image_data = _image_file.read() Category(category_id).update(title=_title, group_id=_group_id, image_data=_image_data, status=_status) return HttpResponseRedirect( reverse('management_edit_category', kwargs={"category_id": category_id}))
def new_entity(request): if request.method == 'GET': return render_to_response('entity/new.html', {'active_division': 'entity'}, context_instance=RequestContext(request)) else: _cand_url = request.POST.get("url", None) _hostname = urlparse(_cand_url).hostname if re.search(r"\b(jd|360buy)\.com$", _hostname) != None: return new_jd_item(request) if re.search(r"\b(tmall|taobao)\.com$", _hostname) != None: _taobao_id = parse_taobao_id_from_url(_cand_url) _item = Item.get_item_by_taobao_id(_taobao_id) if _item == None: _taobao_item_info = load_taobao_item_info(_taobao_id) _brand = '' _title = '' _selected_category_id = Category.get_category_by_taobao_cid( _taobao_item_info['cid']) _users = _get_special_names(request.user.id) return render_to_response( 'entity/create.html', { 'active_division': 'entity', 'taobao_id': _taobao_id, 'cid': _taobao_item_info['cid'], 'taobao_title': _taobao_item_info['title'], 'shop_nick': _taobao_item_info['nick'], 'shop_link': _taobao_item_info['shop_link'], 'price': _taobao_item_info['price'], 'thumb_images': _taobao_item_info["thumb_images"], 'selected_category_id': _selected_category_id, 'category_list': Category.find(), 'brand': _brand, 'title': _title, 'users': _users }, context_instance=RequestContext(request)) elif _item.get_entity_id() == -1: #TODO: bind an exist item to entity pass else: return HttpResponseRedirect( reverse('management_edit_entity', kwargs={"entity_id": _item.get_entity_id()}) + '?code=1')
def create_category(request): if request.method == 'GET': _group_id = request.GET.get("gid", None) if _group_id != None: _group_id = int(_group_id) _category_groups = Category.allgroups() return render_to_response('category/create.html', { 'active_division': 'category', 'category_groups': _category_groups, 'selected_group_id': _group_id, }, context_instance=RequestContext(request)) elif request.method == 'POST': _group_id = request.POST.get("group_id", None) _title = request.POST.get("title", None) _category = Category.create(title=_title, group_id=_group_id) return HttpResponseRedirect( reverse('management_entity_list') + '?cid=' + str(_category.category_id))
def search_entity(request): if request.method == 'POST': _query = request.POST.get("query", None) elif request.method == 'GET': _query = request.GET.get("q", None) _category_groups = Category.allgroups() # _entity_id_list = Entity.find(like_word = _query) _entity_context_list = [] _category_title_dict = Category.get_category_title_dict() # for _entity_id in _entity_id_list: # _entity = Entity(_entity_id) # _entity_context = _entity.read() # _entity_context['category_title'] = _category_title_dict[_entity_context['category_id']] # if _entity_context.has_key('item_id_list') and len(_entity_context['item_id_list']): # _item_context = Item(_entity_context['item_id_list'][0]).read() # _entity_context['buy_link'] = _item_context['buy_link'] # _entity_context['taobao_title'] = _item_context['title'] # else: # _entity_context['buy_link'] = '' # _entity_context['taobao_title'] = '' # _entity_context_list.append(_entity_context) _category_context_list = Category.find(like_word=_query) return render_to_response( 'entity/search.html', { 'active_division': 'entity', 'query': _query, 'category_groups': _category_groups, #'entity_context_list' : _entity_context_list, 'entity_context_list': [], 'category_context_list': _category_context_list, }, context_instance=RequestContext(request))
def load_item_info(request): if request.method == 'POST': _cand_url = request.POST.get("cand_url", None) _hostname = urlparse(_cand_url).hostname if re.search(r"\b(jd|360buy)\.com$", _hostname) != None: return jd_info(request, _cand_url) if re.search(r"\b(tmall|taobao)\.com$", _hostname) is not None: _taobao_id = parse_taobao_id_from_url(_cand_url) _item = Item.get_item_by_taobao_id(_taobao_id) if _item is None: _taobao_item_info = load_taobao_item_info(_taobao_id) _chief_image_url = _taobao_item_info["thumb_images"][0] _selected_category_id = Category.get_category_by_taobao_cid(_taobao_item_info['cid']) _data = { 'user_context' : User(request.user.id).read(), 'cand_url' : _cand_url, 'taobao_id': _taobao_id, 'cid': _taobao_item_info['cid'], 'taobao_title': _taobao_item_info['title'], 'shop_nick': _taobao_item_info['shop_nick'], 'shop_link': _taobao_item_info['shop_link'], 'price': _taobao_item_info['price'], 'chief_image_url' : _chief_image_url, 'thumb_images': _taobao_item_info["thumb_images"], 'selected_category_id': _selected_category_id, } _rslt = { 'status' : 'SUCCESS', 'data' : _data } elif _item.get_entity_id() == -1: _rslt = { 'status' : 'OTHER' } else: _entity_id = _item.get_entity_id() _entity_context = Entity(_entity_id).read() _rslt = { 'status' : 'EXIST', 'data' : { 'entity_hash' : _entity_context['entity_hash'] } } return HttpResponse(json.dumps(_rslt))
def get_guoku_plus_item_context(taobao_url, shop_nick, user_id): if not is_taobao_url(taobao_url): raise NotTaobaoUrl() taobao_id = parse_taobao_id_from_url(taobao_url) if not taobao_id: raise InvalidUrl() item_inst = Item.get_item_by_taobao_id(taobao_id) if not item_inst: taobao_item_info = TaobaoExtractor.fetch_item(taobao_id) print taobao_item_info _category_id = Category.get_category_by_taobao_cid( taobao_item_info['cid']) _chief_image = None _detail_image_urls = [] imgs_len = len(taobao_item_info['imgs']) if imgs_len > 0: _chief_image = taobao_item_info['imgs'][0] for i in range(1, imgs_len): _detail_image_urls.append(taobao_item_info['imgs'][i]) _title = HTMLParser.HTMLParser().unescape(taobao_item_info['desc']) Entity.create_by_taobao_item(creator_id=user_id, category_id=_category_id, chief_image_url=_chief_image, taobao_item_info={ 'taobao_id': taobao_id, 'cid': taobao_item_info['cid'], 'title': _title, 'shop_nick': unicode(taobao_item_info['nick'], 'utf-8'), 'price': taobao_item_info['price'], 'soldout': False, }, brand="", title=_title, detail_image_urls=_detail_image_urls) item_inst = Item.get_item_by_taobao_id(taobao_id) item_context = item_inst.read() if item_context['shop_nick'] != shop_nick: raise NotSellerOwnProduct() return item_context
def user_tag_entity_list(request, user_id, tag): _page_num = int(request.GET.get("p", "1")) _entity_id_list = Tag.find_user_tag_entity(user_id, tag) _paginator = Paginator(_page_num, 30, len(_entity_id_list)) _category_title_dict = Category.get_category_title_dict() _user_context = User(user_id).read() _entity_context_list = [] for _entity_id in _entity_id_list[_paginator.offset : _paginator.offset + _paginator.count_in_one_page]: try: _entity = Entity(_entity_id) _entity_context = _entity.read() _entity_context['category_title'] = _category_title_dict[_entity_context['category_id']] _entity_context['commission_rate'] = -1 _entity_context['commission_type'] = 'unknown' if _entity_context.has_key('item_id_list') and len(_entity_context['item_id_list']): _item_context = Item(_entity_context['item_id_list'][0]).read() _entity_context['buy_link'] = _item_context['buy_link'] _entity_context['taobao_title'] = _item_context['title'] _entity_context['taobao_id'] = _item_context['taobao_id'] _entity_context['taobao_shop_nick'] = _item_context['shop_nick'] if _item_context.has_key('shop_nick'): _shop_context = TaobaoShop(_item_context['shop_nick']).read() if _shop_context != None: if _shop_context['extended_info']['commission'] == True: _entity_context['commission_rate'] = _shop_context['extended_info']['commission_rate'] if _shop_context['extended_info']['orientational']: _entity_context['commission_type'] = 'orientational' else: _entity_context['commission_type'] = 'general' else: _entity_context['buy_link'] = '' _entity_context['taobao_title'] = '' _entity_context['taobao_id'] = '' _entity_context['is_selected'] = False if _entity_context.has_key('note_id_list') and len(_entity_context['note_id_list']): for _note_id in _entity_context['note_id_list']: _note_context = Note(_note_id).read() if _note_context['is_selected']: _entity_context['is_selected'] = True break _entity_context_list.append(_entity_context) except Exception, e: pass
def jd_info(request, _cand_url): _jd_id = parse_jd_id_from_url(_cand_url) _item = JDItem.get_item_by_jd_id(_jd_id) _rslt = {} if _item == None: _jd_item_info = load_jd_item_info(_jd_id) _chief_image_url = _jd_item_info['thumb_images'][0] #TODO:进行京东类目转换 #TODO :先用一个cid暂时使用着先 cid = '1512' _selected_category_id = Category.get_category_by_jd_cid(cid) _data = { 'user_context' : User(request.user.id).read(), 'cand_url' : _cand_url, 'jd_id' : _jd_id, 'jd_title' : _jd_item_info['title'], 'shop_nick' : _jd_item_info['nick'], 'shop_link' : _jd_item_info['shop_link'], 'brand' : _jd_item_info['brand'], 'price' : _jd_item_info['price'], 'chief_image_url' : _chief_image_url, 'thumb_images' :[x.replace("/n1/", "/n5/") for x in _jd_item_info['thumb_images']], 'cid' : cid, 'selected_category_id' : _selected_category_id, } _rslt = { 'status' : 'SUCCESS', 'data' : _data } elif _item.get_entity_id() == -1: _rslt = { 'status' : 'OTHER' } else: _entity_id = _item.get_entity_id() _entity_context = Entity(_entity_id).read() _rslt = { 'status' : 'EXIST', 'data' : { 'entity_hash' : _entity_context['entity_hash'] } } return HttpResponse(json.dumps(_rslt))
def sync_entity_without_title(request): _offset = int(request.GET.get('offset', '0')) _count = int(request.GET.get('count', '100')) _category_title_dict = Category.get_category_title_dict() _rslt = [] for _entity_obj in EntityModel.objects.filter( Q(title__isnull=True) | Q(title=''))[_offset:_offset + _count]: try: _title = _category_title_dict[_entity_obj.neo_category_id] _context = { 'entity_id': _entity_obj.id, 'category_title': _title, 'item_titles': [] } for _item_id in Item.find(entity_id=_entity_obj.id): _context['item_titles'].append(Item(_item_id).read()['title']) _rslt.append(_context) except Exception, e: print e
def get_all_categories(request): if request.method == 'GET': result = {} new_category = {} result['new_category'] = new_category result['old_category'] = Old_Category.find() groups_and_categories = Category.all_group_with_full_category() for g_a_c in groups_and_categories: categories = [] for cat in g_a_c['content']: category = { 'category_title': cat['category_title'], 'category_id': cat['category_id'] } categories.append(category) new_category[g_a_c['title']] = categories return HttpResponse(json.dumps(result))
def all_category(request): _all_categories = Category.all_group_with_full_category() return SuccessJsonResponse(_all_categories)
def entity_list(request): _group_id = request.GET.get("gid", None) if _group_id == None: _status = request.GET.get("status", "select") _para = {"status": _status} _page_num = int(request.GET.get("p", "1")) _category_id = request.GET.get("cid", None) if _category_id != None: _category_id = int(_category_id) _category_context = Category(_category_id).read() _category_group_id = _category_context['group_id'] _categories = Category.find(group_id=_category_context['group_id']) for _category in _categories: _category['entity_count'] = Entity.count( _category['category_id']) _para['cid'] = _category_id else: _category_context = None _category_group_id = None _categories = None _category_groups = Category.allgroups() _select_entity_count = Entity.count(category_id=_category_id, status='select') _novus_entity_count = Entity.count(category_id=_category_id, status='novus') _freeze_entity_count = Entity.count(category_id=_category_id, status='freeze') _recycle_entity_count = Entity.count(category_id=_category_id, status='recycle') _sort_by = request.GET.get("sort_by", "time") _reverse = request.GET.get("reverse", None) if _sort_by: _para["sort_by"] = _sort_by _para["reverse"] = _reverse if _reverse == '1': _reverse = True else: _reverse = False _entity_count = Entity.count(category_id=_category_id, status=_status) if _sort_by == 'random': _paginator = None _entity_id_list = Entity.random(status=_status, count=30) else: _paginator = Paginator(_page_num, 30, _entity_count, _para) _entity_id_list = Entity.find(category_id=_category_id, status=_status, offset=_paginator.offset, count=_paginator.count_in_one_page, sort_by=_sort_by, reverse=_reverse) _entity_context_list = [] _category_title_dict = Category.get_category_title_dict() for _entity_id in _entity_id_list: try: _entity = Entity(_entity_id) _entity_context = _entity.read() _entity_context['category_title'] = _category_title_dict[ _entity_context['category_id']] _entity_context['commission_rate'] = -1 _entity_context['commission_type'] = 'unknown' if _entity_context.has_key('item_id_list') and len( _entity_context['item_id_list']): _item_context = Item( _entity_context['item_id_list'][0]).read() if _item_context == None: #jd items _item_context = JDItem( _entity_context['item_id_list'][0]).read() _entity_context['buy_link'] = _item_context['buy_link'] _entity_context['jd_title'] = _item_context['title'] _entity_context['jd_id'] = _item_context['jd_id'] _entity_context['_jd_shop_nick'] = _item_context[ 'shop_nick'] _entity_context['commission_rate'] = 4 #默认设为4 _entity_context['commission_type'] = 'general' else: _entity_context['buy_link'] = _item_context['buy_link'] _entity_context['taobao_title'] = _item_context[ 'title'] _entity_context['taobao_id'] = _item_context[ 'taobao_id'] _entity_context['taobao_shop_nick'] = _item_context[ 'shop_nick'] if _item_context.has_key('shop_nick'): _shop_context = TaobaoShop( _item_context['shop_nick']).read() if _shop_context != None: if _shop_context['extended_info'][ 'commission'] == True: _entity_context[ 'commission_rate'] = _shop_context[ 'extended_info']['commission_rate'] if _shop_context['extended_info'][ 'orientational']: _entity_context[ 'commission_type'] = 'orientational' else: _entity_context[ 'commission_type'] = 'general' else: _entity_context['buy_link'] = '' _entity_context['taobao_title'] = '' _entity_context['taobao_id'] = '' _entity_context['is_selected'] = False if _entity_context.has_key('note_id_list') and len( _entity_context['note_id_list']): for _note_id in _entity_context['note_id_list']: _note_context = Note(_note_id).read() if _note_context['is_selected']: _entity_context['is_selected'] = True break _entity_context_list.append(_entity_context) except Exception, e: pass if _status == 'freeze': UpdateNovusStatImpression.delay(impression_type='list') return render_to_response('entity/list.html', { 'active_division': 'entity', 'status_filter': _status, 'category_context': _category_context, 'category_groups': _category_groups, 'categories': _categories, 'category_group_id': _category_group_id, 'select_entity_count': _select_entity_count, 'novus_entity_count': _novus_entity_count, 'freeze_entity_count': _freeze_entity_count, 'recycle_entity_count': _recycle_entity_count, 'entity_context_list': _entity_context_list, 'paginator': _paginator, 'sort_by': _sort_by, 'reverse': _reverse }, context_instance=RequestContext(request))
def edit_jd_entity(request, entity_id): if request.method == "GET": _code = request.GET.get("code", None) if _code == "1": _message = "京东商品已被创建至本entity" else: _message = None _entity_context = Entity(entity_id).read() _item_context_list = [] for _item_id in JDItem.find(entity_id=entity_id): _item_context = JDItem(_item_id).read() if (not _entity_context.has_key('title') or \ _entity_context['title'] == "") and \ (not _entity_context.has_key('recommend_title')): _entity_context['recommend_title'] = _item_context['title'] _item_context['commission_type'] = "unknown" _item_context['commission_rate'] = 4 #jd的佣金是根据品类来区分的 _entity_context['commission_type'] = "general" _item_context_list.append(_item_context) _note_count = Note.count(entity_id=entity_id) _users = _get_special_names(request.user.id) _mark_list = Entity.Mark.all() return render_to_response('entity/edit.html', { 'active_division': 'entity', 'entity_context': _entity_context, 'category_list': Category.find(), 'old_category_list': Old_Category.find(), 'item_context_list': _item_context_list, 'mark_list': _mark_list, 'message': _message, 'note_count': _note_count, 'users': _users }, context_instance=RequestContext(request)) elif request.method == "POST": _brand = request.POST.get("brand", None) _title = request.POST.get("title", None) _intro = request.POST.get("intro", None) _price = request.POST.get("price", None) _reset_created_time = request.POST.get("reset_created_time", "off") if _reset_created_time == "on": _reset_created_time = True else: _reset_created_time = False _weight = int(request.POST.get("weight", '0')) _mark = int(request.POST.get("mark", '0')) _chief_image_id = request.POST.get("chief_image", None) if _price: _price = float(_price) _category_id = request.POST.get("category_id", None) if _category_id: _category_id = int(_category_id) _old_category_id = request.POST.get("old_category_id", None) if _old_category_id: _old_category_id = int(_old_category_id) _entity = Entity(entity_id) _entity.update(category_id=_category_id, old_category_id=_old_category_id, brand=_brand, title=_title, intro=_intro, price=_price, chief_image_id=_chief_image_id, weight=_weight, mark=_mark, reset_created_time=_reset_created_time) _note = request.POST.get("note", None) _user_id = request.POST.get("user_id", None) if _note != None and len(_note) > 0: _add_note_and_select_delay(_entity, _user_id, _note) return HttpResponseRedirect(request.META['HTTP_REFERER'])
def edit_entity(request, entity_id): if request.method == 'GET': _code = request.GET.get("code", None) _source = request.GET.get("source", "taobao") if _source == "jd": return edit_jd_entity(request, entity_id) if _code == "1": _message = "淘宝商品已被创建至本entity" else: _message = None _entity_context = Entity(entity_id).read() _item_context_list = [] for _item_id in Item.find(entity_id=entity_id): _item_context = Item(_item_id).read() if _item_context == None: return edit_jd_entity(request, entity_id) if (not _entity_context.has_key('title') or _entity_context['title'] == "") and ( not _entity_context.has_key('recommend_title')): _entity_context['recommend_title'] = _item_context['title'] _item_context['commission_type'] = 'unknown' _item_context['commission_rate'] = -1 if _item_context.has_key('shop_nick'): _shop_context = TaobaoShop(_item_context['shop_nick']).read() if _shop_context != None: if _shop_context['extended_info']['commission'] == True: _item_context['commission_rate'] = _shop_context[ 'extended_info']['commission_rate'] if _shop_context['extended_info']['orientational']: _entity_context[ 'commission_type'] = 'orientational' else: _entity_context['commission_type'] = 'general' _item_context_list.append(_item_context) _note_count = Note.count(entity_id=entity_id) _users = _get_special_names(request.user.id) _mark_list = Entity.Mark.all() if _entity_context['weight'] < 0: UpdateNovusStatImpression.delay(impression_type='edit') return render_to_response('entity/edit.html', { 'active_division': 'entity', 'entity_context': _entity_context, 'category_list': Category.find(), 'old_category_list': Old_Category.find(), 'item_context_list': _item_context_list, 'mark_list': _mark_list, 'message': _message, 'note_count': _note_count, 'users': _users }, context_instance=RequestContext(request)) elif request.method == 'POST': _brand = request.POST.get("brand", None) _title = request.POST.get("title", None) _intro = request.POST.get("intro", None) _price = request.POST.get("price", None) _weight = int(request.POST.get("weight", '0')) _mark = int(request.POST.get("mark", '0')) _chief_image_id = request.POST.get("chief_image", None) if _price: _price = float(_price) _category_id = request.POST.get("category_id", None) if _category_id: _category_id = int(_category_id) _old_category_id = request.POST.get("old_category_id", None) if _old_category_id: _old_category_id = int(_old_category_id) _entity = Entity(entity_id) _entity.update( category_id=_category_id, old_category_id=_old_category_id, brand=_brand, title=_title, intro=_intro, price=_price, chief_image_id=_chief_image_id, weight=_weight, mark=_mark, ) _note = request.POST.get("note", None) _user_id = request.POST.get("user_id", None) if _note != None and len(_note) > 0: _add_note_and_select_delay(_entity, _user_id, _note) return HttpResponseRedirect(request.META['HTTP_REFERER'])
'category_context': _category_context, 'category_groups': _category_groups, 'categories': _categories, 'category_group_id': _category_group_id, 'select_entity_count': _select_entity_count, 'novus_entity_count': _novus_entity_count, 'freeze_entity_count': _freeze_entity_count, 'recycle_entity_count': _recycle_entity_count, 'entity_context_list': _entity_context_list, 'paginator': _paginator, 'sort_by': _sort_by, 'reverse': _reverse }, context_instance=RequestContext(request)) else: _categories = Category.find(group_id=int(_group_id)) _category_groups = Category.allgroups() if len(_categories) == 0: _normal_entity_count = 0 _freeze_entity_count = 0 return render_to_response('entity/list.html', { 'active_division': 'entity', 'category_context': None, 'category_groups': _category_groups, 'categories': _categories, 'category_group_id': int(_group_id), 'normal_entity_count': _normal_entity_count, 'freeze_entity_count': _freeze_entity_count, 'entity_context_list': [], }, context_instance=RequestContext(request))
def group_category(value): _category_context = Category(value).read() _category_group = Category_Group(_category_context['group_id']).read() log.info(_category_group) return _category_group['title']
def create_entity_from_offline(request): if request.method == 'POST': _taobao_id = request.POST.get("taobao_id", None) _cid = request.POST.get("cid", None) _taobao_shop_nick = request.POST.get("taobao_shop_nick", None) _taobao_title = request.POST.get("taobao_title", None) _taobao_price = request.POST.get("taobao_price", None) _taobao_soldout = request.POST.get("taobao_soldout", '0') if _taobao_soldout == '0': _taobao_soldout = False else: _taobao_soldout = True _rank_score = int(request.POST.get("item_score", '0')) _chief_image_url = request.POST.get("chief_image_url", None) _chief_image_url = re.sub('_\d+x\d+\.jpg|_b.jpg', '', _chief_image_url) _brand = request.POST.get("brand", "") _title = request.POST.get("title", "") _intro = request.POST.get("intro", "") _category_id = Category.get_category_by_taobao_cid(_cid) _origin_detail_image_urls = request.POST.getlist("image_url") _detail_image_urls = [] for _url in _origin_detail_image_urls: _detail_image_urls.append(re.sub('_\d+x\d+\.jpg|_b.jpg', '', _url)) if _chief_image_url in _detail_image_urls: _detail_image_urls.remove(_chief_image_url) _item = Item.get_item_by_taobao_id(_taobao_id) if _item == None: _entity = Entity.create_by_taobao_item( creator_id=request.user.id, category_id=_category_id, chief_image_url=_chief_image_url, taobao_item_info={ 'taobao_id': _taobao_id, 'cid': _cid, 'title': _taobao_title, 'shop_nick': _taobao_shop_nick, 'price': _taobao_price, 'soldout': _taobao_soldout, }, brand=_brand, title=_title, intro=_intro, detail_image_urls=_detail_image_urls, weight=-1, rank_score=_rank_score) _rslt = { 'entity_id': _entity.entity_id, 'item_id': _entity.read()['item_id_list'][0], 'status': 'success' } return SuccessJsonResponse(_rslt) else: _item.update(cid=_cid, title=_taobao_title, shop_nick=_taobao_shop_nick, price=_taobao_price, soldout=_taobao_soldout) _rslt = { 'message': 'item_exist', 'item_id': _item.item_id, 'status': 'updated' } return SuccessJsonResponse(_rslt)
def add_category(self, name, match_type, match_priority): category = Category(name, match_type, match_priority) self.categories[name] = category
def trans_category(value): _category_context = Category(value).read() log.info(_category_context) _title = _category_context['category_title'].split('-')[0] return _title