예제 #1
0
def activate(request, eventid, uuid):
    # create a participant since these people will be signing up ONLY via coupon
    # if they were dumb enough to try and signup manually, this'll still catch em
    # This is all bastard code and it will never have a home or a family

    event = Event.objects.get(id=eventid)
    participant = Participant.objects.get_or_create(user=request.user, event=event)[0]
    if participant.coupon:
        return render(request, 'events/already_activated.html', {
            'event':event
        })

    if request.method == 'POST':
        form = WaiverForm(request.POST)
        if form.is_valid():
            print uuid
            coupon = Coupon.objects.get(uuid=uuid)
            try:
                activate_coupon(participant, coupon)
            except IntegrityError:
                return render(request, 'events/coupon_used.html', {
                    'event':event
                    })
            return render(request, 'events/activated.html', {
                'event':event
            })
    else:
        form = WaiverForm()

    return render(request, 'events/activate.html', {
        'form': form,
        'event': event,
    })
예제 #2
0
def payment(request):
    event = Event.objects.get(is_active=True)
    user = request.user
    quantity = request.session['qty']
    total_amount = int(quantity * event.prepay_price * 100) # this is how we deal with sqlite's bullshit
    if request.method == 'POST':
        token = request.POST['stripeToken']
        try:
            charge = stripe.Charge.create(
              amount=total_amount,
              currency="usd",
              card=token, # obtained with Stripe.js
              metadata={'user_email': user.email}
            )
        except stripe.CardError, e:
            return HttpResponseServerError('card failure detected')
        del request.session['qty']
        # we do this so that the Coupon objects actually have their correct types
        coupons = [Coupon(stripe_transaction=charge.id, event=event) for i in xrange(quantity)]
        for coupon in coupons:
            coupon.save()
        # I cannot see a better way to do this at the moment, so here we are
        # We pop the last coupon off the list to activate the ticket for the original payer
        participant = Participant.objects.get_or_create(user=user, event=event)[0]
        coupon = coupons.pop()
        activate_coupon(participant, coupon)
        # We need to dispatch off an email...
        email_confirmation(participant=participant, coupons=coupons)
        return HttpResponseRedirect(reverse('events_register', args=(event.id,))) 
예제 #3
0
def activate(request, eventid, uuid):
    # create a participant since these people will be signing up ONLY via coupon
    # if they were dumb enough to try and signup manually, this'll still catch em
    event = Event.objects.get(id=eventid)
    participant = Participant.objects.get_or_create(user=request.user, event=event)[0]
    if participant.coupon:
        return render(request, 'events/already_activated.html', {
            'event':event
        })
    else:
        coupon = Coupon.objects.get(uuid=uuid)
        try:
            activate_coupon(participant, coupon)
        except IntegrityError:
            return render(request, 'events/coupon_used.html', {
                'event':event
                })
        return render(request, 'events/activated.html', {
            'event':event
        })