def contest_finish(request, context, qforms, contestant_form):
    contest = context['object']
    email = contestant_form.cleaned_data['email']
    if Contestant.objects.filter(email=email, contest=contest).count() > 0:
        context.update({
                'duplicate' : True,
                'forms' : qforms,
                'contestant_form' : contestant_form,
            })
        return render_to_response(
            get_templates_from_publishable('form.html', context['object']),
            context,
            context_instance=RequestContext(request)
        )

    choices = '|'.join(
            '%d:%s' % (
                    question.id,
                    question.allow_multiple and ','.join(str(c.id) for c in sorted(f.cleaned_data['choice'], key=lambda ch: ch.id)) or f.cleaned_data['choice'].id)
                for question, f in sorted(qforms, key=lambda q: q[0].id)
        )
    c = Contestant(
            contest=contest,
            choices=choices,
            **contestant_form.cleaned_data
        )
    if request.user.is_authenticated():
        c.user = request.user
    c.save()
    return HttpResponseRedirect(contest.get_absolute_url() + slugify(ugettext('result')) + u'/')