Code

Ticket #1659: karma.2.diff

File karma.2.diff, 1.5 KB (added by ubernostrum, 8 years ago)

Missed a manager method

Line 
1Index: karma.py
2===================================================================
3--- karma.py    (revision 2653)
4+++ karma.py    (working copy)
5@@ -1,7 +1,7 @@
6 from django.http import Http404
7 from django.shortcuts import render_to_response
8 from django.template import RequestContext
9-from django.models.comments import comments, karma
10+from django.contrib.comments.models import Comment, KarmaScore
11 
12 def vote(request, comment_id, vote):
13     """
14@@ -18,12 +18,12 @@
15     if request.user.is_anonymous():
16         raise Http404, _("Anonymous users cannot vote")
17     try:
18-        comment = comments.get_object(pk=comment_id)
19-    except comments.CommentDoesNotExist:
20+        comment = Comment.objects.get(pk=comment_id)
21+    except Comment.DoesNotExist:
22         raise Http404, _("Invalid comment ID")
23-    if comment.user_id == request.user.id:
24+    if comment.user.id == request.user.id:
25         raise Http404, _("No voting for yourself")
26-    karma.vote(request.user.id, comment_id, rating)
27+    KarmaScore.objects.vote(request.user.id, comment_id, rating)
28     # Reload comment to ensure we have up to date karma count
29-    comment = comments.get_object(pk=comment_id)
30-    return render_to_response('comments/karma_vote_accepted', {'comment': comment}, context_instance=RequestContext(request))
31+    comment = Comment.objects.get(pk=comment_id)
32+    return render_to_response('comments/karma_vote_accepted.html', {'comment': comment}, context_instance=RequestContext(request))