Пример #1
0
def cart_view(request, template_name="cart/cart.html"):
    cart_id = cart.get_cart_id(request)
    cart_items = CartItem.objects.filter(cart_id=cart_id)

    return render_to_response(template_name,
                              locals(),
                              context_instance=RequestContext(request))
Пример #2
0
def submitorder(request):

	if request.method == 'POST':

		email = request.POST['email']
		name = request.POST['name']
		phone = request.POST['phone']

		try:
			user = User.objects.get(email=email)
			user.backend = 'django.contrib.auth.backends.ModelBackend'
			login(request, user)

		except:
			username = email.split('@')[0]
			new_user = create_user(username)

		cart_id = cart.get_cart_id(request)
		cart_items = CartItem.objects.filter(cart_id=cart_id)
		cart_items_text = ''
		for item in cart_items:
			cart_items_text += item.product.name

		subject = u'заявка от %s' % name
		message = u'Имя: %s \n телефон: %s\n email: %s \n продукты: %s' % (name, phone, email, cart_items_text)
		send_mail(subject, message, '*****@*****.**', [ADMIN_EMAIL], fail_silently=False)

		subject = u'заявка от %s' % name
		message = u'С уважением компания Рокит'
		send_mail(subject, message, '*****@*****.**', [email], fail_silently=False)


	data = json.dumps({})
	return HttpResponse(data, content_type="application/json")
Пример #3
0
def add_to_cart(request):
    id = request.POST["id"]
    product = Product.objects.get(id=id)
    cart_id = cart.get_cart_id(request)
    # parametr_price = request.POST['parametr_price']
    # parametr = ProductParametr.objects.get(product=product, price=parametr_price)

    try:
        tmp_item = CartItem.objects.get(cart_id=cart_id, product=product)
        tmp_item.count += int(request.POST["count"])
        tmp_item.save()
        return tmp_item
    except:
        cartItem = CartItem()
        cartItem.product = product
        cartItem.count = request.POST["count"]
        cartItem.cart_id = cart_id
        cartItem.save()
        return cartItem
Пример #4
0
def add_to_cart(request):
    id = request.POST['id']
    product = Product.objects.get(id=id)
    print product
    cart_id = cart.get_cart_id(request)
    # parametr_price = request.POST['parametr_price']
    # parametr = ProductParametr.objects.get(product=product, price=parametr_price)

    try:
        tmp_item = CartItem.objects.get(cart_id=cart_id, product=product)
        tmp_item.count += int(request.POST['count'])
        tmp_item.save()
        return tmp_item
    except:
        cartItem = CartItem()
        cartItem.product = product
        cartItem.count = request.POST['count']
        cartItem.cart_id = cart_id
        cartItem.save()
        return cartItem
Пример #5
0
def submitorder(request):

    if request.method == 'POST':

        email = request.POST['email']
        name = request.POST['name']
        phone = request.POST['phone']

        try:
            user = User.objects.get(email=email)
            user.backend = 'django.contrib.auth.backends.ModelBackend'
            login(request, user)

        except:
            username = email.split('@')[0]
            new_user = create_user(username)

        cart_id = cart.get_cart_id(request)
        cart_items = CartItem.objects.filter(cart_id=cart_id)
        cart_items_text = ''
        for item in cart_items:
            cart_items_text += item.product.name

        subject = u'заявка от %s' % name
        message = u'Имя: %s \n телефон: %s\n email: %s \n продукты: %s' % (
            name, phone, email, cart_items_text)
        send_mail(subject,
                  message,
                  '*****@*****.**', [ADMIN_EMAIL],
                  fail_silently=False)

        subject = u'заявка от %s' % name
        message = u'С уважением компания Рокит'
        send_mail(subject,
                  message,
                  '*****@*****.**', [email],
                  fail_silently=False)

    data = json.dumps({})
    return HttpResponse(data, content_type="application/json")
Пример #6
0
def getcartitems(request):
    cart_id = cart.get_cart_id(request)
    cartitems = CartItem.objects.filter(cart_id=cart_id)
    data = serializeCartItems(cartitems)
    return HttpResponse(data, content_type="application/json")
Пример #7
0
def getcartitems(request):
	cart_id = cart.get_cart_id(request)
	cartitems = CartItem.objects.filter(cart_id=cart_id)
	data = serializeCartItems(cartitems)
	return HttpResponse(data, content_type="application/json")
Пример #8
0
def cart_view(request, template_name="cart/cart.html"):
    cart_id = cart.get_cart_id(request)
    cart_items = CartItem.objects.filter(cart_id=cart_id)

    return render_to_response(template_name, locals(), context_instance=RequestContext(request))