def METHOD_NAME(request, poll_id):
    """
    View for registering a vote for the logged in user.
    """
    poll = get_object_or_404(Poll, pk=poll_id)
    try:
        choice = poll.choices.get(pk=request.POST["choice"])
        choice.METHOD_NAME(request.user)
    except (KeyError, Choice.DoesNotExist):
        messages.warning(request, "Du valgte ikke et svaralternativ")
    except UserHasVoted:
        messages.error(request, "Du har allerede stemt i denne avstemningen!")
    else:
        messages.success(request, f'Du har svart på "{poll.question}"')
    redirect_to = request.POST.get("next", request.META.get("HTTP_REFERER", "/"))
    return redirect(redirect_to)