Ticket #1659: karma.2.diff

File karma.2.diff, 1.5 KB (added by James Bennett, 19 years ago)

Missed a manager method

  • karma.py

     
    11from django.http import Http404
    22from django.shortcuts import render_to_response
    33from django.template import RequestContext
    4 from django.models.comments import comments, karma
     4from django.contrib.comments.models import Comment, KarmaScore
    55
    66def vote(request, comment_id, vote):
    77    """
     
    1818    if request.user.is_anonymous():
    1919        raise Http404, _("Anonymous users cannot vote")
    2020    try:
    21         comment = comments.get_object(pk=comment_id)
    22     except comments.CommentDoesNotExist:
     21        comment = Comment.objects.get(pk=comment_id)
     22    except Comment.DoesNotExist:
    2323        raise Http404, _("Invalid comment ID")
    24     if comment.user_id == request.user.id:
     24    if comment.user.id == request.user.id:
    2525        raise Http404, _("No voting for yourself")
    26     karma.vote(request.user.id, comment_id, rating)
     26    KarmaScore.objects.vote(request.user.id, comment_id, rating)
    2727    # Reload comment to ensure we have up to date karma count
    28     comment = comments.get_object(pk=comment_id)
    29     return render_to_response('comments/karma_vote_accepted', {'comment': comment}, context_instance=RequestContext(request))
     28    comment = Comment.objects.get(pk=comment_id)
     29    return render_to_response('comments/karma_vote_accepted.html', {'comment': comment}, context_instance=RequestContext(request))
Back to Top