コード例 #1
0
ファイル: SubscriptionManager.py プロジェクト: kmax12/lts
def checkout(request, cart, student, name, customer, email, student_email=None, password=None):
    print cart
    c = charge_customer(cart.total(), customer["id"], email)

    cart.checkout()
    
    send_reciept(
        total = cart.total(),
        supplies = cart.get_supplies(),
        to_email = email,
        name = name,
    )


    if student:
        email_student_supplies(
            supplies = cart.get_supplies(),
            from_name = name,
            to_email = student_email
        )
    else:
        create_user_with_subscriptions(name, email, password, cart.get_supplies())

        user = authenticate(username=email, password=password)
        login(request, user)
コード例 #2
0
ファイル: views.py プロジェクト: kmax12/lts
def claim_gift(request):
    post = request.POST
    error = ""

    code = request.GET.get("code", None)
    if post:
        code = post.get("code", None)

    if not code:
        return redirect("lifetime.views.buy_supply")

    try:
        gift = Gift.objects.get(code=code)

        if gift.claimed:
            return redirect("lifetime.views.buy_supply")
    except:
        return redirect("lifetime.views.buy_supply")

    if post:
        form = ClaimGift(post)
        if form.is_valid():
            form_data = form.cleaned_data
            create_user_with_subscriptions(
                form_data["name"], form_data["email"], form_data["password"], gift.supplies.all()
            )
            user = authenticate(username=form_data["email"], password=form_data["password"])
            login(request, user)
            gift.claimed = True
            gift.save()
            return redirect("account.views.account")
    else:
        form = ClaimGift()

    template_values = {"gift": gift, "form": form}

    return direct_to_template(request, "claim_gift.html", template_values)