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


Python Cart.remove_single方法代码示例

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


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

示例1: remove_single

# 需要导入模块: from carton.cart import Cart [as 别名]
# 或者: from carton.cart.Cart import remove_single [as 别名]
def remove_single(request):
    cart = Cart(request.session)
    initial_count = cart.count
    product = products[int(request.POST.get('product_id'))]
    cart.remove_single(product)
    after_rmv_count = cart.count
    assert initial_count == after_rmv_count + 1
    return HttpResponse()
开发者ID:jongabriel,项目名称:django-carton,代码行数:10,代码来源:views.py

示例2: remove

# 需要导入模块: from carton.cart import Cart [as 别名]
# 或者: from carton.cart.Cart import remove_single [as 别名]
def remove(request):
    cart = Cart(request.session)
    event = Event.objects.get(id=request.GET.get('id'))
    cart.remove_single(event)

    messages.success(request, "Event removed from basket")

    return render(request, 'ticket/cart/basket.html')
开发者ID:mohsin-mulla,项目名称:bandpunch,代码行数:10,代码来源:views.py

示例3: remove_single

# 需要导入模块: from carton.cart import Cart [as 别名]
# 或者: from carton.cart.Cart import remove_single [as 别名]
def remove_single(request, product_id):
    cart = Cart(request.session)
    if Item2.objects.filter(product_id=product_id):
        product = Item2.objects.get(product_id=product_id)
    elif Item3.objects.filter(product_id=product_id):
        product = Item3.objects.get(product_id=product_id)
    else:
        product = Item4.objects.get(product_id=product_id)
    cart.remove_single(product)
    return HttpResponseRedirect('/tohfa/show')
开发者ID:ritz1302,项目名称:giftwebsite,代码行数:12,代码来源:views.py

示例4: remove

# 需要导入模块: from carton.cart import Cart [as 别名]
# 或者: from carton.cart.Cart import remove_single [as 别名]
def remove(request):
	cart = Cart(request.session)
	product_id = request.GET.get('id')
	product = Product.objects.get(id=product_id)
	is_unique = is_product_qty_unique(request, product_id)
	cart.remove_single(product)
	html = new_cart_html(request,0)
	cart_contents_qty = cart_contents_payload_unique(request, is_unique, product_id)
	payload = update_cart_status_and_prepare_payload(request, html, cart_contents_qty, True)
	return HttpResponse(json.dumps(payload), content_type="application/json")
开发者ID:vlameiras,项目名称:cdkeyswholesale,代码行数:12,代码来源:views.py

示例5: remove_from_cart

# 需要导入模块: from carton.cart import Cart [as 别名]
# 或者: from carton.cart.Cart import remove_single [as 别名]
def remove_from_cart(request, slug):
    if request.is_ajax():
        cart = Cart(request.session)
        product = get_object_or_404(Product, slug=slug)
        cart.remove_single(product)
        return render_to_response('mcat_order/cart.html',
                                   context_instance=RequestContext(request),
                                   content_type="application/xhtml+xml"
                                   )
    else:
        if settings.DEBUG:
            print("Not ajax request")
        raise Http404
开发者ID:synw,项目名称:django-mcat-order,代码行数:15,代码来源:views.py

示例6: CartTests

# 需要导入模块: from carton.cart import Cart [as 别名]
# 或者: from carton.cart.Cart import remove_single [as 别名]

#.........这里部分代码省略.........
        Are items in the cart counted correctly?
        """
        self.cart.add(self.deer, 10.00, 2)
        self.cart.add(self.moose, 20.00, 1)
        self.session.save()

        response = self.show_response()

        self.assertContains(response, 'items count: 3')
        self.assertContains(response, 'unique count: 2')

    def test_products_are_removed_all_together(self):
        """
        Can all products of a single type be removed?
        """
        self.cart.add(self.deer, 10.00, 3)
        self.cart.add(self.moose, 20.00, 1)
        self.session.save()

        self.cart.remove(self.deer)

        response = self.show_response()

        self.assertNotContains(response, 'deer')
        self.assertContains(response, 'moose')

    def test_single_product_is_removed(self):
        """
        Can a single instance of a product be removed?
        """
        self.cart.add(self.deer, 10.00, 3)
        self.session.save()

        self.cart.remove_single(self.deer)

        self.assertContains(self.show_response(), '2 deer')

    def test_quantity_is_overwritten(self):
        """
        Can an items quantity be changed?
        """
        self.cart.add(self.deer, 10.00, 3)
        self.session.save()

        self.cart.set_quantity(self.deer, 4)

        self.assertContains(self.show_response(), '4 deer')

    def test_cart_items_are_cleared(self):
        """
        Can a cart be entirely cleared?
        """
        self.cart.add(self.deer, 10.00, 1)
        self.cart.add(self.moose, 20.00, 1)
        self.cart.clear()
        self.session.save()

        response = self.show_response()

        self.assertNotContains(response, 'deer')
        self.assertNotContains(response, 'moose')

    @override_settings(CART_PRODUCT_LOOKUP={'price__gt': 1})
    def test_custom_product_filter_are_applied(self):
        """
        We modify the cart queryset to exclude some products. We
开发者ID:Matt-Deacalion,项目名称:django-carton,代码行数:70,代码来源:tests.py

示例7: remove_single

# 需要导入模块: from carton.cart import Cart [as 别名]
# 或者: from carton.cart.Cart import remove_single [as 别名]
def remove_single(request):
    cart = Cart(request.session)
    product = Product.objects.get(pk=request.POST.get('product_id'))
    cart.remove_single(product)
    return HttpResponse()
开发者ID:50c10,项目名称:django-carton,代码行数:7,代码来源:views.py

示例8: remove_single

# 需要导入模块: from carton.cart import Cart [as 别名]
# 或者: from carton.cart.Cart import remove_single [as 别名]
def remove_single(request, id):
    cart = Cart(request.session)
    product = get_object_or_404(models.Product, pk=id)
    cart.remove_single(product)
    return HttpResponseRedirect('../../../card/showcard')
开发者ID:kostaa94,项目名称:site,代码行数:7,代码来源:views.py

示例9: remove_single

# 需要导入模块: from carton.cart import Cart [as 别名]
# 或者: from carton.cart.Cart import remove_single [as 别名]
def remove_single(request, id):
    cart = Cart(request.session)
    product = get_object_or_404(models.Product, pk=id)
    cart.remove_single(product)
    return HttpResponse({product.price:'pr' })
开发者ID:boyxiaolong,项目名称:shop-1,代码行数:7,代码来源:views.py

示例10: remove_single

# 需要导入模块: from carton.cart import Cart [as 别名]
# 或者: from carton.cart.Cart import remove_single [as 别名]
def remove_single(request):
	cart = Cart(request.session)
	plato = Plato.objects.get(id=request.GET.get('product_id'))
	cart.remove_single(plato)
	return platilla_cesta(request);
开发者ID:gamezinfantes,项目名称:UFood,代码行数:7,代码来源:views.py


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