本文整理汇总了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)+"¬e="+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))
示例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)
示例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)
示例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')
示例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', '/'))
示例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
示例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))
示例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)))
示例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')
示例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 )
示例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')
示例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)
示例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))
示例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)
示例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', '/'))