Пример #1
0
    def post(self, request):
        order = Order()
        order.cart_id = request.session.get(CART_ID)
        order.address = request.POST.get('address')
        order.phone = request.POST.get('phone')
        order.name = request.POST.get('name')
        order.processed = False
        order.comment = request.POST.get('comment')
        if request.user.is_authenticated():
            order.customer = request.user
        order.save()

        cart = CartService(request)
        cart.checkout()

        params = {
            "phone": unicode(request.POST.get('phone')),
            "name": None,
            "customer": request.user,
            "comment": order.comment,
            "orderno": order.id,
            "orderdt": order.checkout_date,
            "orderaddr": order.address,
            "ordercart": cart,
        }

        send_notification("order_notice", params)

        return render(request, 'cart/after_order.html')
Пример #2
0
    def post(self, request):
        user = request.user
        if user.is_authenticated():
            role = 'Авторизированный пользователь {}'.format(user.id)
            if user.role == user.ROLE_WHOLESALER:
                role = 'Наш оптовик {}'.format(user.id)
        else:
            role = 'Навторизированный пользователь'

        params = {
            "phone": unicode(request.POST["phone"]),
            "name": unicode(request.POST["name"]),
            "user_role": role,
            "dt": datetime.now()
        }
        try:
            send_notification("callme_back", params)
        except Exception as e:
            logger.error("Cannot send callme_back notification: %s" % str(e))
            return HttpResponse(json.dumps({"ok": 0}),
                                content_type="application/json")

        response = HttpResponse(json.dumps({"ok": 1}),
                                content_type="application/json")
        return response
Пример #3
0
    def post(self, request):
        user = request.user
        if user.is_authenticated():
            role = 'Авторизированный пользователь {}'.format(user.id)
            if user.role == user.ROLE_WHOLESALER:
                role = 'Наш оптовик {}'.format(user.id)
        else:
            role = 'Навторизированный пользователь'

        params = {
            "phone": unicode(request.POST["phone"]),
            "name": unicode(request.POST["name"]),
            "user_role": role,
            "dt": datetime.now()
        }
        try:
            send_notification("callme_back", params)
        except Exception as e:
            logger.error("Cannot send callme_back notification: %s" % str(e))
            return HttpResponse(json.dumps({"ok": 0}),
                                content_type="application/json")

        response = HttpResponse(json.dumps({"ok": 1}),
                                content_type="application/json")
        return response
Пример #4
0
    def post(self, request):
        order = Order()
        order.cart_id = request.session.get(CART_ID)
        order.address = request.POST.get('address')
        order.phone = request.POST.get('phone')
        order.name = request.POST.get('name')
        order.processed = False
        order.comment = request.POST.get('comment')
        if request.user.is_authenticated():
            order.customer = request.user
        order.save()

        cart = CartService(request)
        cart.checkout()

        params = {
            "phone": unicode(request.POST.get('phone')),
            "name": None,
            "customer": request.user,
            "comment": order.comment,
            "orderno": order.id,
            "orderdt": order.checkout_date,
            "orderaddr": order.address,
            "ordercart": cart,
        }

        send_notification("order_notice", params)

        return render(request, 'cart/after_order.html')
Пример #5
0
    def handle(self, *args, **options):
        handled = False
        images_archive = options.get("images_archive")
        if images_archive and os.path.exists(images_archive):
            attach_images(images_archive)
            self.stderr.write("Loaded images from %s" % images_archive)
            handled = True

        csv_file = options.get("csv_file")
        if csv_file and os.path.exists(csv_file):
            load_csv(csv_file)
            self.stderr.write("Imported csv file %s" % csv_file)
            handled = True

        if not handled:
            raise CommandError("No valid import files specified!")
        else:
            params = {
                "images_archive": images_archive,
                "csv_file": csv_file,
            }
            send_notification("load_items", params)
Пример #6
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
Пример #7
0
    def handle(self, *args, **options):
        handled = False
        images_archive = options.get("images_archive")
        if images_archive and os.path.exists(images_archive):
            attach_images(images_archive)
            self.stderr.write("Loaded images from %s" % images_archive)
            handled = True

        csv_file = options.get("csv_file")
        if csv_file and os.path.exists(csv_file):
            load_csv(csv_file)
            self.stderr.write("Imported csv file %s" % csv_file)
            handled = True

        if not handled:
            raise CommandError("No valid import files specified!")
        else:
            params = {
                "images_archive": images_archive,
                "csv_file": csv_file,
            }
            send_notification("load_items", params)
Пример #8
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