当前位置: 首页>>代码示例>>Python>>正文


Python Cart.remove方法代码示例

本文整理汇总了Python中cart.Cart.remove方法的典型用法代码示例。如果您正苦于以下问题:Python Cart.remove方法的具体用法?Python Cart.remove怎么用?Python Cart.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cart.Cart的用法示例。


在下文中一共展示了Cart.remove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_cart

# 需要导入模块: from cart import Cart [as 别名]
# 或者: from cart.Cart import remove [as 别名]
def get_cart(request, slug):
	if request.method == 'GET':
		venue = get_object_or_404(Venue, slug=slug)
		itemlist = MenuItem.objects.filter(venue=venue)
		cart = Cart(request)
		cart_total = cart.cart_total()
	if request.method == 'POST':
		venue = get_object_or_404(Venue, slug=slug)
		itemlist = MenuItem.objects.filter(venue=venue)
		cart = Cart(request)
		for item in cart:
			id = item.object_id
			menu_item = get_object_or_404(MenuItem, id=id)
			name = str(item.product.item_name)
			remove_name = name+'_remove'
			if remove_name in request.POST:
				cart.remove(menu_item)
			else:
				quantity = request.POST[name]
				if quantity:
					cart.update(menu_item, quantity, item.unit_price)
		return HttpResponseRedirect(reverse('kiosk.views.get_cart', args=(slug,)))
	note_list = []
	for item in cart:
		note_list.append(str(item.quantity)+" "+item.product.item_name)
	note = ", ".join(note_list)
	link_note = urllib.quote(note)	
	link = 'https://venmo.com?txn=Pay&recipients='+venue.venmo_account+'&amount='+str(cart_total)+"&note="+link_note	
	content = dict(venue=venue, cart=cart, cart_total=cart_total, link=link, note=note)
	return render_to_response('kiosk/cart.html', content, context_instance=RequestContext(request))
开发者ID:jstanchak,项目名称:Map-and-Kiosk,代码行数:32,代码来源:views.py

示例2: remove_from_cart

# 需要导入模块: from cart import Cart [as 别名]
# 或者: from cart.Cart import remove [as 别名]
def remove_from_cart(request):
    product_id = request.POST['product_id']
    kw = get_kwrgs(request)
    product = Product.objects.get(id=product_id)
    cart = Cart(request)
    cart.remove(product)
    return render(request, 'shop/cart.html', kw)
开发者ID:Adviser-ua,项目名称:blueberry,代码行数:9,代码来源:views.py

示例3: ajax_eliminaritem

# 需要导入模块: from cart import Cart [as 别名]
# 或者: from cart.Cart import remove [as 别名]
def ajax_eliminaritem(request):
	product_id=request.POST["item_id"]
 	product = Producto.objects.get(id=product_id)
 	cart = Cart(request)
 	cart.remove(product)
 	total_carrito =cart.total_cart
 	return HttpResponse(total_carrito)
开发者ID:MaikolEdu,项目名称:Tiendavirtual,代码行数:9,代码来源:views.py

示例4: empty_cart

# 需要导入模块: from cart import Cart [as 别名]
# 或者: from cart.Cart import remove [as 别名]
def empty_cart(request):
    cart = Cart(request)
    transaction = models.create_transaction(request.user)

    for item in cart:
        item.product.unlock_seat(transaction)
        cart.remove(item.product)
    return redirect('cart')
开发者ID:kamaldaniels,项目名称:pvy,代码行数:10,代码来源:views.py

示例5: remove_addon_from_cart

# 需要导入模块: from cart import Cart [as 别名]
# 或者: from cart.Cart import remove [as 别名]
def remove_addon_from_cart(request, addon_pk):
    cart = Cart(request)
    item = get_object_or_404(Addon, pk=addon_pk)
    try:
        cart.remove(item)
    except ItemDoesNotExist:
        return redirect('catalog:cart')
    return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/'))
开发者ID:stden,项目名称:colortek,代码行数:10,代码来源:views.py

示例6: remove

# 需要导入模块: from cart import Cart [as 别名]
# 或者: from cart.Cart import remove [as 别名]
def remove(request):
    if(request.is_ajax() and request.POST):
        video = get_object_or_404(Video, pk=request.POST['video_pk'])
        cart = Cart(request)
        cart.remove(video)
        return HttpResponse("{'success':true}", mimetype="application/json")
    else:
        raise Http404
开发者ID:destos,项目名称:godjango-site,代码行数:10,代码来源:views.py

示例7: remove_from_cart

# 需要导入模块: from cart import Cart [as 别名]
# 或者: from cart.Cart import remove [as 别名]
def remove_from_cart(request, product_id):
#    form = my_form(request.GET)
#    if form.is_valid():
    product = Product.objects.get(id=product_id)
    cart = Cart(request)
    cart.remove(product)
    return render_to_response('cart/cart.html', dict(cart=Cart(request)),
                                  context_instance=RequestContext(request))
开发者ID:HeisSuperHan,项目名称:djangoShop,代码行数:10,代码来源:views.py

示例8: confirm

# 需要导入模块: from cart import Cart [as 别名]
# 或者: from cart.Cart import remove [as 别名]
def confirm(request):
    # mark the seats as paid and remove from cart
    cart = Cart(request)
    transaction = models.create_transaction(request.user)

    for item in cart:
        item.product.pay_seat(transaction, request.user)
        cart.remove(item.product)
    return render(request, 'confirm.html', dict(cart=Cart(request)))
开发者ID:kamaldaniels,项目名称:pvy,代码行数:11,代码来源:views.py

示例9: user_logout

# 需要导入模块: from cart import Cart [as 别名]
# 或者: from cart.Cart import remove [as 别名]
def user_logout(request):
    # empty the cart
    cart = Cart(request)
    transaction = models.create_transaction(request.user)
    for item in cart:
        item.product.unlock_seat(transaction)
        cart.remove(item.product)
    logout(request)
    return redirect('login')
开发者ID:kamaldaniels,项目名称:pvy,代码行数:11,代码来源:views.py

示例10: remove_from_cart

# 需要导入模块: from cart import Cart [as 别名]
# 或者: from cart.Cart import remove [as 别名]
def remove_from_cart(request):
	cart = Cart(request)
	if request.method == 'POST':
		print "hello"
		product_id = request.POST.get('key')
		product_id = int(product_id) - 1
		product = Item.objects.get(id=product_id)
		cart.remove(product)
	initalData = dict(cart=Cart(request))
	csrfContext = RequestContext(request, initalData)
	return render_to_response('cart.html',csrfContext )
开发者ID:pnpatel89,项目名称:vendstor-dev,代码行数:13,代码来源:views.py

示例11: remove_from_cart

# 需要导入模块: from cart import Cart [as 别名]
# 或者: from cart.Cart import remove [as 别名]
def remove_from_cart(request):
    supply_id = request.GET.get('id', None)
    response_data = {}
    response_data['success'] = False
    if (supply_id):
        supply = Supply.objects.get(id=supply_id)
        cart = Cart(request)
        cart.remove(supply)
        response_data['success'] = True

    return redirect('cart.views.view_cart')
开发者ID:kmax12,项目名称:lts,代码行数:13,代码来源:views.py

示例12: add_to_cart

# 需要导入模块: from cart import Cart [as 别名]
# 或者: from cart.Cart import remove [as 别名]
def add_to_cart(request):
    product_id = request.POST['product_id']
    qty = request.POST['qty']
    product = Product.objects.get(id=product_id)
    cart = Cart(request)
    if in_cart(cart, product_id):
        cart.remove(product)
        cart.add(product, product.price, qty)
    else:
        cart.add(product, product.price)
    mykwrgs = get_kwrgs(request)
    return render(request, 'shop/cart.html', mykwrgs)
开发者ID:Adviser-ua,项目名称:blueberry,代码行数:14,代码来源:views.py

示例13: get_cart

# 需要导入模块: from cart import Cart [as 别名]
# 或者: from cart.Cart import remove [as 别名]
def get_cart(request):
    if request.method == 'POST':
        pedido = Pedido()

        tamano = int(request.POST['tamano'])
        print 'tamaño'+str(tamano)
        id_direccion = int(request.POST['direccion'])
        precio_total = float(request.POST['precio_total'])

        #LLENAMOS LOS DATOS BASICOS PARA EL PEDIDO
        pedido.direccion = Direccion.objects.get(id = id_direccion)
        pedido.usuario = request.user
        pedido.precio_total = precio_total

        #GUARDAMOS EL PEDIDO
        pedido.save()

        for i in range(1, tamano+1):

            #INSTANCIAMOS UN DETALLEPEDIDO
            detallePedido = DetallePedido()

            #RECUPERAMOS EL VALOR DEL ID DEL CATALOGO
            id_catalogo = int(request.POST['catalogo-%s' % i])

            #RECUPERAMOS LA CANTIDAD DE PRODUCTO PEDIDO
            cantidad = int(request.POST['cantidad-%s' % i])

            #OBTENEMOS UN OBJETO CATALOGO
            catalogo = Catalogo.objects.get(id=id_catalogo)
            print catalogo

            #UTILIZAMOS ESTA INFORMACION PARA EL DETALLEPEDIDO
            detallePedido.pedido = pedido
            detallePedido.catalogo = catalogo
            detallePedido.cantidad = cantidad

            #GUARDAMOS EL DETALLE
            detallePedido.save()

            print 'iteracion: %s' % i

        ruta = '/pedidos/detalle/%s/' % pedido.id

        cart = Cart(request)
        for i in cart:
            cart.remove(i.product)
        return HttpResponseRedirect(ruta)

    else:
        direcciones = Direccion.objects.all()
        ctx = {'cart': Cart(request), 'direcciones':direcciones}
        return render_to_response('carrito.html', ctx, context_instance=RequestContext(request))
开发者ID:fesquivelc,项目名称:appjaveros,代码行数:55,代码来源:views.py

示例14: empty_cart

# 需要导入模块: from cart import Cart [as 别名]
# 或者: from cart.Cart import remove [as 别名]
def empty_cart(request):
    cart = Cart(request)
    transaction = Transaction(user=request.user)
    transaction.save()

    for item in cart:
        item.product.unlock_seat(transaction)
        cart.remove(item.product)

    context = {'total': 0}

    html = render(request, 'cart.html', context)
    return StreamingHttpResponse(html)
开发者ID:kamaldaniels,项目名称:pvk,代码行数:15,代码来源:views.py

示例15: remove_item_from_cart

# 需要导入模块: from cart import Cart [as 别名]
# 或者: from cart.Cart import remove [as 别名]
def remove_item_from_cart(request, item_pk):
    cart = Cart(request)
    item = get_object_or_404(Item, pk=item_pk)
    item_ct = get_model_content_type(Item)
    addon_ct = get_model_content_type(Addon)
    try:
        cart.remove(item)
        items = cart.cart.item_set.filter(content_type=item_ct).count()
        if items == 0:
            # remove all addons if items drops to zero
            cart.cart.item_set.filter(content_type=addon_ct).delete()
    except ItemDoesNotExist:
        return redirect('catalog:cart')
    return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/'))
开发者ID:stden,项目名称:colortek,代码行数:16,代码来源:views.py


注:本文中的cart.Cart.remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。