Example #1
0
def bulk_export(request):
    if request.method == 'POST':
        form = GameSelectForm(request.POST)
        if form.is_valid():
            game = form.cleaned_data['gameselect']
            exported = []
            for x in game.code_set.filter(used = False):
                exported.append(x.code)
                x.uuid_assign('codenarok-' + unicode(x.game))
            game.update_count()
            context = {
                'form' : form,
                'game' : game,
                'exported' : exported,
            }

            return render(request, 'dispenser/export.html', context)

    form = GameSelectForm()
    
    context = {
        'form' : form,
    }


    return render(request, 'dispenser/export.html', context)
Example #2
0
def auto_ticket(request):
    #you thought you were going to break things by not having an e-mail? ha!
    if not request.user.email:
        return redirect('account/email')
    if request.method == 'POST':
        game = AutoCode()
        #!!!
        #let's talk about security sometime...(...later)(...never)
        up = UserProfile.objects.get(user = request.user)
        if 'ticket_random' in request.POST:
            if up.ticket_decrement(1):
                if not game.code_rand(request.user.email):
#this wouldn't be necessary if I didn't do these 'function evaluates t/f' things
                    up.ticket_increment(1) 
                    return HttpResponse('Oops<br>You have been refunded.')
            else:
                return HttpResponse('not enough tickets: '+str(up.ticket_count))
        elif 'ticket_selection' in request.POST:
            gsf = GameSelectForm(request.POST)
            if gsf.is_valid():
                if up.ticket_decrement(2):
                    if not game.code_select(request.user.email, gsf.cleaned_data['gameselect'].id):
                        up.ticket_increment(2)
                        return HttpResponse('Oops<br>You have been refunded.')
                else:
                    return HttpResponse('not enough tickets: '+str(up.ticket_count))
            else:
                return HttpResponse('invalid choice')
            
#TODO
        print game
        print str(game.code)
        attach_code = game
        subject = 'Here is your requested code!'
        if attach_code:
            url_get = game.get_url_get()
            url_return = game.get_url_return()
        #hahaha, oh wow what is this mess
            message = '<br>' + 'Here is a code for ' + str(game.game) +'.<br> To redeem it, go to '+url_get+'<br>If you would like to return it to us, go to '+url_return
        else:
            message = '<br>Unfortunately, we are out of codes for '+str(game.game) + '.' 
        print message
        donation_mail = mailbot.pack_MIME(message, request.user.email, subject)
        mailbot.send_mail(donation_mail, request.user.email)
        
   
        diagnostic = str(game.game.id)
        return HttpResponse('Check your email for your gift of '+str(game.game)+ '<br>'+diagnostic)
    return HttpResponse('huh?')
Example #3
0
def retrieve(request):
    if request.method == 'POST':
        gsf = GameSelectForm(request.POST)
        if not gsf.is_valid():
            return HttpResponse('I don\'t know how you messed that up, but you did. Nice going.')
        else:
            url = '/dispenser/retrieve/get/' + str(gsf.cleaned_data['gameselect'].id)
            print url
            return redirect(url)
    else:
        game_select = GameSelectForm
        context = {
            'form' : '/dispenser/retrieve/',
            'game_select' : game_select,
        }
        return render(request, 'dispenser/retrieve.html', context)