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


Python Order.order_id方法代码示例

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


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

示例1: checkout

# 需要导入模块: from orders.models import Order [as 别名]
# 或者: from orders.models.Order import order_id [as 别名]
def checkout(request):

    ## using the session we created during carts to collect the cart_id.
    try:
        the_id = request.session['cart_id']
        cart= Cart.objects.get(id= the_id)
        print cart
    except :
        the_id= None
    ## Redirects to a url that we had initially configured in django urls page
        return HttpResponseRedirect(reverse("cart"))

# Creating a new instance if there is no order present. This instance will be saved as the
# new order.
    try:
        new_order = Order.objects.get(cart=cart)
    except Order.DoesNotExist:
        new_order = Order()
        new_order.cart = cart
        new_order.user = request.user
        new_order.order_id = id_generator()
        new_order.save()
   # it will return the user back to the cart
    except:
        return HttpResponseRedirect(reverse("cart"))




   # If the order is indicated as finished the cart will be deleted as well as
    # resetting the total number of items back to zero.
    if new_order.status== "Finished":
        del request.session['cart_id']
        del request.session['items_total']
        return HttpResponseRedirect(reverse("cart"))

    context={}
    return render(request, "products/home.html", context)
开发者ID:cmwaura,项目名称:Ecommerce-Application,代码行数:40,代码来源:views.py

示例2: checkout_saved_cc

# 需要导入模块: from orders.models import Order [as 别名]
# 或者: from orders.models.Order import order_id [as 别名]
def checkout_saved_cc(request):
    try:
        the_cart_id = request.session['cart_id']
        cart = Cart.objects.get(id=the_cart_id)
        subbies = CartItem.subbie_type.filter(cart=cart)
        singles = CartItem.single_type.filter(cart=cart)
        cart_items = CartItem.objects.filter(cart=cart)
        cc_id = request.POST['ccRadios']
        cc = CreditCard.objects.get(id=cc_id)
    except:
        the_cart_id = None
        return HttpResponseRedirect(reverse("view_cart"))
    try:
        user = request.user
    except:
        user = None

    try:
        new_order = Order.objects.get(cart=cart)
    except Order.DoesNotExist:
        new_order = Order()
        new_order.cart = cart
        new_order.order_id = id_generator()
        new_order.save()
    except:
        new_order = None
        return HttpResponseRedirect(reverse("view_cart"))

    if request.POST:
        order = new_order
        amount = int(order.total * 100)  # convert to cents
        fee = int(order.total * 100 * settings.TRINITY_FEE * .01)  # % of inputed ($) amount, in cents
        customer = cc.stripe_id
        try:
            charge = stripe.Charge.create(
                amount=amount,  # amount in cents, again
                currency="usd",
                application_fee=fee,
                customer=customer,
                api_key=settings.TRINITY_API_KEY,
            )

            order.status = "Finished"
            order.payer_name = cc.payer_name
            order.payer_email = cc.payer_email
            order.last4 = cc.last4
            order.card_type = cc.card_type
            order.save()

            order_id = order.order_id
            # make records here:
            # get recipient, check for last record. is last record greater than sub. first issue?
            # first look for latest record for this recipient, if greater than subscription.first_issue

            print "HERE in checkout-cc, we are going to make recrods"

            print "order is %s" % order
            print "cart is %s" % cart
            print "cart items is %s" % cart_items
            print "subbies is %s" % subbies
            print "singlges is %s" % singles

            for sub in subbies:
                # two paths here- regular subbie and renewal
                print "wea are in subbie path"
                recipient = sub.recipient
                print recipient
                print "type is %s" % sub.subscription.type
                if sub.subscription.type == 2:  # renewal
                    print "chcekout cc, renewal"
                    last_record = Record.objects.filter(recipient=recipient).order_by('issue').last()
                    ish = last_record.issue + 1
                else:  # not renewal
                    print "checkout cc not renewal"
                    ish = sub.subscription.first_issue

                # try:
                #    all_record = Record.objects.get(recipient=sub.recipient, originating_order=order, issue=ish)

                for x in range(0, sub.subscription.term):
                    try:
                        record = Record.objects.get(recipient=sub.recipient, originating_order=order, issue=ish)
                        pass
                    except Record.DoesNotExist:
                        new_record = Record(recipient=sub.recipient, originating_order=order, issue=ish)
                        new_record.save()
                    ish += 1

            for single in singles:
                ish = int(single.single.slug)
                print "cehkout cc single"
                try:
                    bo = BackIssue.objects.get(
                        recipient=order.main_recipient, originating_order=order, issue=ish, quantity=single.quantity)
                    pass
                except BackIssue.DoesNotExist:
                    new_bo = BackIssue(
                        recipient=order.main_recipient, originating_order=order, issue=ish, quantity=single.quantity)
                    new_bo.save()

#.........这里部分代码省略.........
开发者ID:davogler,项目名称:POSTv3,代码行数:103,代码来源:views.py

示例3: checkout

# 需要导入模块: from orders.models import Order [as 别名]
# 或者: from orders.models.Order import order_id [as 别名]
def checkout(request):
    try:
        the_cart_id = request.session['cart_id']
        cart = Cart.objects.get(id=the_cart_id)
        subbies = CartItem.subbie_type.filter(cart=cart)
        singles = CartItem.single_type.filter(cart=cart)
        cart_items = CartItem.objects.filter(cart=cart)

    except:
        the_cart_id = None
        return HttpResponseRedirect(reverse("view_cart"))

    try:
        user = request.user
    except:
        user = None

    try:

        new_order = Order.objects.get(cart=cart)
    except Order.DoesNotExist:
        new_order = Order()
        new_order.cart = cart
        new_order.order_id = id_generator()
        new_order.save()
    except:
        new_order = None
        return HttpResponseRedirect(reverse("view_cart"))

    if request.user.is_authenticated():
        new_order.user = request.user
        print new_order.user
        print "we gota  new order user"

    new_order.total = cart.total
    new_order.shipping = cart.shipping_total
    if new_order.coupon:
        coupon = new_order.coupon
        percent_discount = coupon.percent_discount
        new_total = new_order.total - new_order.total * (float(percent_discount) / 100)
        print new_total
        new_order.total = new_total
    new_order.save()
    pay_form = PayForm()
    order = new_order

    subgo = False
    singo = False
    paygo = False
    usergo = False

    if subbies and singles:
        for sub in subbies:
            if sub.recipient:
                subgo = True
            else:
                subgo = False
        if order.main_recipient:
            singo = True
        else:
            singo = False

        if subgo == True and singo == True:
            paygo = True
        else:
            paygo = False

    elif not subbies and singles:
        if order.main_recipient:
            singo = True
        else:
            singo = False

        if subgo == False and singo == True:
            paygo = True
        else:
            paygo = False

    elif subbies and not singles:
        for sub in subbies:
            if sub.recipient:
                subgo = True
            else:
                subgo = False

        if subgo == True and singo == False:
            paygo = True
        else:
            paygo = False

    # check user status
    user = request.user
    if user.is_authenticated():
        usergo = True
    elif singles and not subbies:
        usergo = True
    else:
        usergo = False

    if request.POST:
#.........这里部分代码省略.........
开发者ID:davogler,项目名称:POSTv3,代码行数:103,代码来源:views.py

示例4: checkout_auto_renewal

# 需要导入模块: from orders.models import Order [as 别名]
# 或者: from orders.models.Order import order_id [as 别名]
def checkout_auto_renewal(request):
    """for admin charging of auto renews"""
    customer = request.POST.get('ccStripeId', "")
    record_id = request.POST.get('recordId', "")
    user_id = request.POST.get('userId', "")
    issue = request.POST.get('issueNo', "")
    cc = CreditCard.objects.get(stripe_id=customer)
    user = User.objects.get(id=user_id)
    record = Record.objects.get(id=record_id)
    sub = Subscription.objects.get(sku="pbrenewal")

    cart = Cart(user=user)
    cart.save()
    cart_item = CartItem(cart=cart,
                         subscription=sub,
                         flug=sub.slug,
                         line_total=sub.price,
                         recipient=record.recipient,
                         )
    cart_item.save()
    cart.product_total = cart_item.line_total
    cart.total = cart_item.line_total
    cart.save()
    order=Order(cart=cart,
                user=user,
                total=cart.total,
                payer_name=user.get_full_name(),
                payer_email=user.email,
                )
    order.order_id = id_generator()
    order.save()
    amount = int(order.total * 100)  # convert to cents
    fee = int(order.total * 100 * settings.TRINITY_FEE * .01)  # % of inputed ($) amount, in cents
    try:
        charge = stripe.Charge.create(
            amount=amount,  # amount in cents, again
            currency="usd",
            application_fee=fee,
            customer=customer,
            api_key=settings.TRINITY_API_KEY,
        )

        order.status = "Finished"
        order.last4 = cc.last4
        order.card_type = cc.card_type
        order.save()

        recipient = record.recipient
        last_record = Record.objects.filter(recipient=recipient).order_by('issue').last()
        ish = last_record.issue + 1
        # try:
        #    all_record = Record.objects.get(recipient=sub.recipient, originating_order=order, issue=ish)

        for x in range(0, cart_item.subscription.term):
            try:
                record = Record.objects.get(recipient=recipient, originating_order=order, issue=ish)
                pass
            except Record.DoesNotExist:
                new_record = Record(recipient=recipient, originating_order=order, issue=ish)
                new_record.save()
            ish += 1

        order.status = "Recorded"
        order.save()

        # now we notify.
        subbies = CartItem.subbie_type.filter(cart=cart)
        current_site = Site.objects.get_current()
        local = settings.LOCAL
        email_context = {
            "cart": cart,
            "subbies": subbies,
            "order": order,
            "current_site": current_site,
            "local": local,
        }

        if settings.EMAIL_NOTIFICATIONS is True:
            recipient = order.payer_email
            print "email notifications are true and we're about to send to %s" % recipient

            purchase_notify(email_context, recipient)

        else:
            print "email settings not true"
            pass

    except stripe.CardError, e:

        # Since it's a decline, stripe.error.CardError will be caught
        body = e.json_body
        err = body['error']

        print "Status is: %s" % e.http_status
        print "Type is: %s" % err['type']
        print "Code is: %s" % err['code']

        print "Message is: %s" % err['message']
        messages.error(request, "%s The payment could not be completed." % err['message'])
开发者ID:davogler,项目名称:POSTv3,代码行数:101,代码来源:views.py


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