def contest_view(request, contestid): context = globalContext(request) if settings.HIGH_TRAFFIC: return render(request, 'disabled.html', context) contest = get_object_or_404(contest_models.Contest.objects.select_related( 'suggested_by', 'image_by'), pk=contestid) if not is_current_contest(contest): return redirect('/contest/result/' + contestid + '/' + tourldash(contest.name) + '/') vote = request.POST.get('vote_side', None) if not vote: vote = request.POST.get('right', None) if not vote: vote = request.POST.get('left', None) if (request.method == 'POST' and (vote == 'right' or vote == 'left')): votesession = contest_models.Session.objects.get( token=request.session['token']) if votesession: validate_vote(vote, votesession, contest) reused_session, cards = get_votesession(request, contest) request.session['token'] = cards.token context.update({ 'reused_session': reused_session, 'cards': cards, 'contest': contest, 'token': cards.token, 'contest_max_sessions': settings.CONTEST_MAX_SESSIONS, }) return render(request, 'contest.html', context)
def contest_view(request, contestid): context = globalContext(request) contest = get_object_or_404(contest_models.Contest, pk=contestid) if not is_current_contest(contest): return redirect('/contest/result/' + contestid + '/' + tourldash(contest.name) + '/') if request.method == 'POST': try: votesession = contest_models.Session.objects.get(token=request.session['token']) if votesession: choice = 'left' if request.POST.has_key('left') else 'right' validate_vote(choice, votesession, contest) except: pass cards = get_votesession(request, contest) request.session['token'] = cards.token context.update({ 'cards': cards, 'contest': contest, 'token': cards.token, }) return render(request, 'contest.html', context)
def contest_view(request, contestid): context = globalContext(request) if settings.HIGH_TRAFFIC: return render(request, 'disabled.html', context) contest = get_object_or_404(contest_models.Contest.objects.select_related('suggested_by', 'image_by'), pk=contestid) if not is_current_contest(contest): return redirect('/contest/result/' + contestid + '/' + tourldash(contest.name) + '/') if (request.method == 'POST' and 'vote_side' in request.POST and request.POST['vote_side'] and (request.POST['vote_side'] == 'right' or request.POST['vote_side'] == 'left')): votesession = contest_models.Session.objects.get(token=request.session['token']) if votesession: choice = request.POST['vote_side'] validate_vote(choice, votesession, contest) reused_session, cards = get_votesession(request, contest) request.session['token'] = cards.token context.update({ 'reused_session': reused_session, 'cards': cards, 'contest': contest, 'token': cards.token, 'contest_max_sessions': settings.CONTEST_MAX_SESSIONS, }) return render(request, 'contest.html', context)