def new_jd_item(request): _cand_url = request.POST.get("url", None) _jd_id = parse_jd_id_from_url(_cand_url) _item = JDItem.get_item_by_jd_id(_jd_id) if _item == None: _jd_item_info = load_jd_item_info(_jd_id) _users = _get_special_names(request.user.id) return render_to_response('entity/create_jd.html', { 'active_division': 'entity', 'jd_id': _jd_id, 'category': _jd_item_info['category'], 'jd_title': _jd_item_info['title'], 'shop_nick': _jd_item_info['nick'], 'shop_link': _jd_item_info['shop_link'], 'price': _jd_item_info['price'], 'thumb_images': _jd_item_info['thumb_images'], 'brand': _jd_item_info['brand'], 'title': _jd_item_info['title'], 'users': _users, 'selected_category_id': "" }, context_instance=RequestContext(request)) elif _item.get_entity_id() == -1: pass else: return HttpResponseRedirect( reverse('management_edit_jd_entity', kwargs={'entity_id': _item.get_entity_id()}) + '?code=1')
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))