def vote(request, comment_id, vote):
 rating = {'up': 1, 'down': (-1)}.get(vote, False)
 if (not rating):
  raise Http404, 'Invalid vote'
 if (not request.user.is_authenticated()):
  raise Http404, _('Anonymous users cannot vote')
 try:
  comment = Comment.objects.get(pk=comment_id)
 except Comment.DoesNotExist:
  raise Http404, _('Invalid comment ID')
 if (comment.user.id == request.user.id):
  raise Http404, _('No voting for yourself')
 KarmaScore.objects.vote(request.user.id, comment_id, rating)
 comment = Comment.objects.get(pk=comment_id)
 return render_to_response('comments/karma_vote_accepted.html', {'comment': comment}, context_instance=RequestContext(request))

def vote ( request , comment_id , vote ) : rating = { 'up' : 1 , 'down' : ( - 1 ) } . get ( vote , False ) if ( not rating ) : raise Http404 , 'Invalid vote' if ( not request . user . is_authenticated ( ) ) : raise Http404 , _ ( 'Anonymous users cannot vote' ) try : comment = Comment . objects . get ( pk = comment_id ) except Comment . DoesNotExist : raise Http404 , _ ( 'Invalid comment ID' ) if ( comment . user . id == request . user . id ) : raise Http404 , _ ( 'No voting for yourself' ) KarmaScore . objects . vote ( request . user . id , comment_id , rating ) comment = Comment . objects . get ( pk = comment_id ) return render_to_response ( 'comments/karma_vote_accepted.html' , { 'comment' : comment } , context_instance = RequestContext ( request ) )
rate a comment templates: karma_vote_accepted context: comment comments .