Exemplo n.º 1
0
 def _create_item_in_database(self,
                              cart,
                              product,
                              quantity=1,
                              unit_price=Decimal("100")):
     item = Item()
     item.cart = cart
     item.product = product
     item.quantity = quantity
     item.unit_price = unit_price
     item.save()
     return item
Exemplo n.º 2
0
    def post(self, request):
        cart = Cart()
        cart.save()
        item = Item()
        item.cart = cart
        item.quantity = int(request.POST.get("quantity", 1))
        item.product_id = int(request.POST["product_id"])
        item.save()

        order = Order()
        order.cart_id = cart.id
        order.address = "Уточнить у клиента"
        order.phone = request.POST.get('phone')
        order.name = request.POST.get('name')
        order.comment = "Заказ в один клик"
        if request.user.is_authenticated():
            order.customer = request.user
        order.save()

        cart_service = CartService(request, cart)

        params = {
            "phone": unicode(request.POST["phone"]),
            "name": unicode(request.POST["name"]),
            "customer": request.user,
            "comment": order.comment,
            "orderno": order.id,
            "orderdt": order.checkout_date,
            "orderaddr": order.address,
            "ordercart": cart_service,
        }

        send_notification("order_notice", params)
        response = HttpResponse(json.dumps({
            "order_id": order.id,
            "ok": 1
        }),
                                content_type="application/json")
        return response
Exemplo n.º 3
0
    def post(self, request):
        cart = Cart()
        cart.save()
        item = Item()
        item.cart = cart
        item.quantity = int(request.POST.get("quantity", 1))
        item.product_id = int(request.POST["product_id"])
        item.save()

        order = Order()
        order.cart_id = cart.id
        order.address = "Уточнить у клиента"
        order.phone = request.POST.get('phone')
        order.name = request.POST.get('name')
        order.comment = "Заказ в один клик"
        if request.user.is_authenticated():
            order.customer = request.user
        order.save()

        cart_service = CartService(request, cart)

        params = {
            "phone": unicode(request.POST["phone"]),
            "name": unicode(request.POST["name"]),
            "customer": request.user,
            "comment": order.comment,
            "orderno": order.id,
            "orderdt": order.checkout_date,
            "orderaddr": order.address,
            "ordercart": cart_service,
        }

        send_notification("order_notice", params)
        response = HttpResponse(json.dumps({"order_id": order.id, "ok": 1}),
                                content_type="application/json")
        return response