代码对比

def get_store_listing(request):
    from common.util import  utc2local
    title = request.GET.get('title','')
    print "title:", title
    searchStatus=request.GET.get('searchStatus','')
    print "searchStatus:",searchStatus
    # listings = MarketStoreActiveListings.objects.filter(channel__market=1,status=1)
    listings=WishVariations.objects.all()
    if title:
        print "title:",title
        if searchStatus=="sku":
            listings = listings.filter(sku=title)
        elif searchStatus=="title":
            listings = listings.filter(wish_product__name=title)
        elif searchStatus=="product_id":
            listings = listings.filter(product_id=title)
    offset=0
    print 1
    try:
        page_size = int(request.GET.get('limit',50))
    except:
        page_size = 50

    try:
        offset = int(request.GET.get('offset',0))
    except:
        offset = 0

    result_list = []
    for each in listings[offset:offset + page_size]:
        each_info = {
            'id':each.id,
            'product_id':each.product_id,
            'sku':each.sku,
            'title':each.wish_product.name,
            'main_image':each.wish_product.main_image,
            'inventory':each.inventory,
            'price':each.price,
            'store_id':each.wish_product.store_id,
            'date_uploaded':str(utc2local(each.wish_product.date_uploaded))[:10],
            'wish_express':each.wish_product.wish_express_country_codes,
            # 'quantity' : each.quantity,
            # 'three_days_sales':each.three_days_sales,
            # 'open_date':str(utc2local(each.update_time))[:10],
            'num_sold': each.wish_product.num_sold,
            'num_saves':each.wish_product.num_saves,
            'color': each.color,
            'size':each.size,
            'shipping':each.shipping,
            'enabled':each.enabled,
            'upload_user_id':each.wish_product.upload_user_id,
            'tags':each.wish_product.tags,
            'description':each.wish_product.description,
            'all_images':each.all_images,
            'main_image':each.wish_product.main_image,
            'local_status':each.wish_product.local_status,
            'store_id':each.wish_product.store_id
            # 'local_status':each.wish_product.status_choice['local_status'],
            # 'stock_name':each.channel.warehouse.warehouse_name,
            # 'on_hold':'',
            # 'feature':'',
        }
        # wh = WarehouseInternalProductsInventories.objects.filter(internal_product=each_info['sku'], warehouse = each.channel.warehouse).first()
        wh = WarehouseInternalProductsInventories.objects.all()
        # if wh:
        #     each_info['on_hold'] = wh.current_inventory
        #     each_info['feature'] = wh.forcasted_inventory
        result_list.append(each_info)
    # print each_info
    return HttpResponse(json.dumps({'total':listings.count(),'rows':result_list}))






def view_products(request):
    numPerPage = 20
    page = 1
    _method = request.method
    type_list = ""
    if _method == 'POST':
        print "post ..."
        store_name = request.POST.get("store_name", "")
        type_list = request.POST.get("type_list", "")
        numPerPage = int(request.POST.get('numPerPage',20))
        sku = request.POST.get('sku','').strip()
        cate_id = request.POST.get('cate_id','')
        title = request.POST.get('title','')
        dateStart = request.POST.get('dateStart','')
        dateEnd = request.POST.get('dateEnd','')
        developer = int(request.POST.get('developer','0'))
        page = request.POST.get('pageNum',1)
        cate_id_name = request.POST.get('cate_id_name','').strip()
        ali = request.POST.get('ali', '0')
        have_added  = request.POST.get('have_added', '0')
        if ali =="on": ali='1'
        view_son = request.POST.get('view_son', '')
        params = {
                  'cate_id':cate_id,
                  'dateEnd':dateEnd,
                  'dateStart':dateStart,
                  'developer':developer,
                  'sku':sku,
                  'title':title,
                  'order_by':'-create_time',
                  'cate_id_name':cate_id_name,
                  'ali': ali,
                'have_added': have_added,
                'numPerPage': numPerPage,
                'page':page,
                'view_son': view_son,
                  }
        products, totalCount = get_products(**params)
    else:
        store_name = request.GET.get("store_name", "")
        cate_id, have_added = request.GET.get("cate_id"), '0'
        ali = request.GET.get("ali", '0')
        view_son = request.GET.get("view_son", '')
        numPerPage = request.GET.get('numPerPage', '20')
        params = {'cate_id':cate_id,'order_by':'-create_time', 'numPerPage': numPerPage}
        products, totalCount = get_products(** params)
    print "-"*100
    developers = get_members_of_group('Developer')

    paginator = Paginator(products, numPerPage)
#     totalCount =  products.count()
    try:
        products = paginator.page(page)
    except Exception,e:
        print e
    except (EmptyPage, InvalidPage):
        products = paginator.page(paginator.num_pages)
    currentPage = page
    #print "products: ",products
    stores = Wish_Account.objects.filter()
    if not store_name: store_name = stores[0]
    print "cate_id:", cate_id
    return render(request,'sale_wish/wish_store.html',locals(),context_instance=RequestContext(request))
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值