Пример #1
0
def order(request, access_code):
    # TODO: Zamówienia usera widoczne tylko dla niego (logowanie potrzebne)
    # TODO: Zamówienia bez usera po podaniu kodu (logowanie nie potrzebne)
    try:
        order = Order.objects.get(access_code=access_code)
    except Order.DoesNotExist:
        HttpResponse('Cant find this object')

    # Zamówione produkty
    ordered_products = Ordered.objects.filter(order=order)
    cart = Cart()

    # Dodanie produktów do klasy (wrappera) - Cart
    for p in ordered_products:
        cart.add_to_cart(Product.objects.get(id=p.product.id), p.amount)

    context = {'order': order, 'cart': cart}
    return render(request, 'transactions/order.html', context)
Пример #2
0
    def test_Cart_add_product_to_cart(self):
        cart = Cart()
        cart.add_to_cart(self.product1, 1)

        self.assertEquals(len(cart.lines), 1)