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


Python Order.address方法代码示例

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


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

示例1: complete_order

# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import address [as 别名]
def complete_order(request):
    request.session.set_expiry(0)
    cart = request.session["cart"]
    order = Order()
    order.first_name = request.POST["first_name"]
    order.last_name = request.POST["last_name"]
    order.address = request.POST["address"]
    order.city = request.POST["city"]
    order.payment_method = request.POST["payment"]
    order.payment_data = request.POST["payment_data"]
    order.items = gen_items_list(cart)
    request.session["cart"] = []
    return render(request, "mystore/complete_order.html", None)
开发者ID:bluehawk27,项目名称:estore,代码行数:15,代码来源:views.py

示例2: completeOrder

# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import address [as 别名]
def completeOrder(request):
  request.session.set_expiry(0)
  cart = request.session['cart']
  order = Order()
  order.first_name = request.POST['first_name']
  order.last_name = request.POST['last_name']
  order.address = request.POST['address']
  order.city = request.POST['city']
  order.payment_method = request.POST['payment']
  order.payment_data = request.POST['payment_data']
  order.items = genItemsList(cart)
  request.session['cart'] = []
  return render(request, "complete_order.html", None)
开发者ID:hnejadi,项目名称:Python-Django-ecommerce-app,代码行数:15,代码来源:views.py

示例3: completeOrder

# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import address [as 别名]
def completeOrder(request):
    cart = request.session['cart']
    request.session.set_expiry(0)
    ctx = {'cart':cart, 'cart_size':len(cart), 'cart_items':cartItems(cart), 'total_price': priceCart(cart)}
    order = Order()
    order.items = genItemsList(cart)
    order.first_name = request.POST['first_name']
    order.last_name = request.POST['last_name']
    order.address = request.POST['address']
    order.city = request.POST['city']
    order.payment_data = request.POST['payment_data']
    order.fulfilled = False
    order.payment_method = request.POST['payment']
    order.save()
    request.session['cart'] = []
    return render(request, "complete_order.html", ctx)
开发者ID:jakegny,项目名称:UdemyClasses,代码行数:18,代码来源:views.py

示例4: show_form

# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import address [as 别名]
def show_form():
    form = OrderForm()

    if form.validate_on_submit():
        bitcoin = bitcoinrpc.connect_to_local()
        order = Order().populate_from_order_form(form)
        order.address = bitcoin.getnewaddress()
        db.session.add(order)
        
        for gb_form in form.group_buys:
            db.session.add(GroupBuy(order = order
                ).populate_from_groupbuy_form(gb_form))
        
        db.session.commit()
        
        return redirect(url_for(".order_completed", address = order.address))
    
    return render_template("index.html",
        form = form, prices = prices, site_name = app.config["SITE_NAME"])
开发者ID:ryepdx,项目名称:klondike_order_form,代码行数:21,代码来源:views.py

示例5: create_order

# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import address [as 别名]
def create_order(request):
    args = {
        'form': OrderForm(),
        'delivery_mass': DeliveryType.objects.all(),
        'user': request.user,
        'user_active': request.user.is_authenticated(),
        'cart_sum': get_sum(request),
    }
    args.update(csrf(request))
    is_valid = True

    if request.user.is_authenticated():
        ord = Order()
        ord.first_name = request.user.first_name
        ord.last_name = request.user.last_name
        ord.email = request.user.email
        ord.phone = request.user.phone
        ord.city = request.user.city
        ord.address = request.user.address
        args['form'] = OrderForm(instance=ord)

    if request.POST:
        if request.POST.get('first_name', "") == "":
            args['user_inform_error'] = True
            args['first_name_error'] = "error_field"
            is_valid = False
        if request.POST.get('last_name', "") == "":
            args['user_inform_error'] = True
            args['last_name_error'] = "error_field"
            is_valid = False
        if request.POST.get('email', "") == "":
            args['user_inform_error'] = True
            args['email_error'] = "error_field"
            is_valid = False
        if request.POST.get('phone', "") == "":
            args['user_inform_error'] = True
            args['phone_error'] = "error_field"
            is_valid = False

        if request.POST.get('city', "") == "":
            args['address_inform_error'] = True
            args['city_error'] = "error_field"
            is_valid = False
        if request.POST.get('address', "") == "":
            args['address_inform_error'] = True
            args['address_error'] = "error_field"
            is_valid = False

        if request.POST.get('delivery', "") == "":
            args['delivery_error'] = "выберите тип доставки"
            args['delivery_error'] = "error_field"
            is_valid = False

        if 'register' in request.POST:
            try:
                email = request.POST.get('email', "")
                User.objects.get(email=email)
                args['register_error'] = "Пользователь с таким email уже разегистрирован"
                is_valid = False
            except User.DoesNotExist:
                pass

        form = OrderForm(request.POST)
        if is_valid and form.is_valid():
            order = form.save(commit=False)
            delivery = DeliveryType.objects.get(id=request.POST['delivery'])
            order.delivery = delivery.title
            order.delivery_price = delivery.price
            order.status = 0
            print(get_sum(request))
            order.sum = get_sum(request)
            if request.user.is_authenticated():
                order.user = request.user
            order.save()
            cart = get_cart(request)
            if cart:
                for pr in CartProduct.objects.filter(cart=cart):
                    if pr.product.sale_status:
                        pr.price_order = pr.product.price_sale
                    else:
                        pr.price_order = pr.product.price
                    pr.save()
                    order.products.add(pr)
            else:
                args['cart_error'] = "в вашей корзине ничего нет"
            order.save()

            if 'register' in request.POST:
                new_user = User()
                new_user.first_name = request.POST.get('first_name', "")
                new_user.last_name = request.POST.get('last_name', "")
                new_user.email = request.POST.get('email', "")
                new_user.phone = request.POST.get('phone', "")
                new_user.city = request.POST.get('city', "")
                new_user.address = request.POST.get('address', "")
                new_user.username = translit(new_user.first_name) + "_" + random_str(6)
                password = random_str(7)
                new_user.set_password(password)
                new_user.save()
                # отправка уведомления
#.........这里部分代码省略.........
开发者ID:VMarshinskii,项目名称:ftrend,代码行数:103,代码来源:views.py

示例6: create_order

# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import address [as 别名]
def create_order(request):
    args = {
        'user': request.user,
        'form': OrderForm(),
        'delivery_mass': DeliveryType.objects.all(),
        'user_active': request.user.is_authenticated(),
        'cart_sum': get_sum(request),
    }
    args.update(csrf(request))
    is_valid = True

    if request.user.is_authenticated():
        ord = Order()
        ord.first_name = request.user.first_name
        ord.last_name = request.user.last_name
        ord.email = request.user.email
        ord.phone = request.user.phone
        ord.index = request.user.index
        ord.address = request.user.address
        # index
        args['form'] = OrderForm(instance=ord)

    if request.POST:

        if request.POST.get('delivery', "") == "":
            args['delivery_error'] = "- выберите тип доставки"
            is_valid = False

        form = OrderForm(request.POST)
        if is_valid and form.is_valid():
            order = form.save(commit=False)
            delivery = DeliveryType.objects.get(id=request.POST['delivery'])
            order.delivery = delivery.title
            order.delivery_price = delivery.price
            order.status = 0
            if request.user.is_authenticated():
                order.user = request.user
            order.sum = delivery.price + get_sum(request)
            order.save()
            cart = get_cart(request)
            if cart:
                for pr in CartProduct.objects.filter(cart=cart):
                    pr.cart = None
                    pr.save()
                    order.products.add(pr)
            else:
                args['cart_error'] = "в вашей корзине ничего нет"
            order.save()

            if request.user.is_authenticated():
                request.user.first_name = request.POST.get('first_name', "")
                request.user.last_name = request.POST.get('last_name', "")
                request.user.phone = request.POST.get('phone', "")
                request.user.address = request.POST.get('address', "")
                request.user.index = request.POST.get('index', "")
                request.user.save()

            email = request.POST.get('email', "")
            t = get_template('create_order_sender.html')
            html_content = t.render(Context({
                'hello': 'Спасибо за заказ на <a href="http://darya-shop.ru">darya-shop.ru</a>!',
                'user_active': request.user.is_authenticated(),
                'order': order,
                'order_status': STATUSES_LIST[order.status],
                'products': order.products.all(),
            }))

            msg = EmailMultiAlternatives("Заказ на Darya-Shop", html_content, "[email protected]", [email, "[email protected]"])
            msg.attach_alternative(html_content, "text/html")
            msg.send()

            return redirect("/orders/thanks/")

        args['form'] = form
    return render_to_response("create_order.html", args)
开发者ID:VMarshinskii,项目名称:dshop,代码行数:77,代码来源:views.py


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