Esempio n. 1
0
def subscriptions_login(req):
    email = req.GET.get('email', req.POST.get('email'))
    if req.GET.get(CONFIRMATION_PARAM):
        validated = validate_confirmation(req)
        if validated:
            try:
                tip_user = TipUser.objects.get(email_address=email)
            except TipUser.DoesNotExist:
                # Verified because they just confirmed their email
                tip_user = TipUser(email=email, verified=True)
                tip_user.save()

            req.session['pay_session'] = tip_user.id
            return redirect('tip_jar_subs')
        # fallthrough

    if not req.POST:
        return _pmrender(req, 'payments/tip_jar/login.html')

    send_email(
        req.POST.get('email'),
        ugettext('Podcast Tip Jar - Email Verification'),
        ugettext(
            'Thanks for verifying your email! Click the link below '
            'to see your podcast subscriptions.'),
        reverse('tip_jar_login') + '?email=%s' % quote(email))

    return _pmrender(req, 'payments/tip_jar/check_email.html')
Esempio n. 2
0
def subscriptions_login(req):
    email = req.GET.get('email', req.POST.get('email'))
    if req.GET.get(CONFIRMATION_PARAM):
        validated = validate_confirmation(req)
        if validated:
            try:
                tip_user = TipUser.objects.get(email_address=email)
            except TipUser.DoesNotExist:
                # Verified because they just confirmed their email
                tip_user = TipUser(email=email, verified=True)
                tip_user.save()

            req.session['pay_session'] = tip_user.id
            return redirect('tip_jar_subs')
        # fallthrough

    if not req.POST:
        return _pmrender(req, 'payments/tip_jar/login.html')

    send_email(
        req.POST.get('email'),
        ugettext('Podcast Tip Jar - Email Verification'),
        ugettext(
            'Thanks for verifying your email! Click the link below '
            'to see your podcast subscriptions.'),
        reverse('tip_jar_login') + '?email=%s' % quote(email))

    return _pmrender(req, 'payments/tip_jar/check_email.html')
Esempio n. 3
0
def confirm_sub(req, podcast_slug):
    if not validate_confirmation(req):
        return _pmrender(req, 'payments/tip_jar/bad_link.html', ctx)

    pod = get_object_or_404(Podcast, slug=podcast_slug)

    try:
        amount = int(req.GET.get('amount'))
    except ValueError:
        return HttpResponse(status=400)
    email = req.GET.get('email')
    token = req.GET.get('token')

    try:
        result = _finish_sub(req, pod, amount, email, token)
        if result:
            return redirect('tip_jar_subs')
    except Exception:
        return HttpResponse(status=400)
Esempio n. 4
0
def confirm_sub(req, podcast_slug):
    if not validate_confirmation(req):
        return _pmrender(req, 'payments/tip_jar/bad_link.html', ctx)

    pod = get_object_or_404(Podcast, slug=podcast_slug)

    try:
        amount = int(req.GET.get('amount'))
    except ValueError:
        return HttpResponse(status=400)
    email = req.GET.get('email')
    token = req.GET.get('token')

    try:
        result = _finish_sub(req, pod, amount, email, token)
        if result:
            return redirect('tip_jar_subs')
    except Exception:
        return HttpResponse(status=400)