]> git.openstreetmap.org Git - osqa.git/commitdiff
#OSQA-388, connecting the award_points command to the BonusRepAction. We take the...
authorjordan <jordan@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Tue, 15 Mar 2011 14:38:14 +0000 (14:38 +0000)
committerjordan <jordan@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Tue, 15 Mar 2011 14:38:14 +0000 (14:38 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@843 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum/views/commands.py

index bd8e373eaacd2621c5400520a0e8040ed2e18d32..0708f631d5d2f6beff6e114983919e419a3f3501 100644 (file)
@@ -555,6 +555,7 @@ def answer_permanent_link(request, id):
 def award_points(request, user_id, answer_id):
     user = request.user
     awarded_user = get_object_or_404(User, id=user_id)
+    answer = get_object_or_404(Answer, id=answer_id)
 
     # Users shouldn't be able to award themselves
     if awarded_user.id == user.id:
@@ -568,4 +569,13 @@ def award_points(request, user_id, answer_id):
         return render_to_response("node/award_points.html", { 'user' : user, 'awarded_user' : awarded_user, })
     else:
         points = int(request.POST['points'])
-        return { 'message' : _("You have awarded %s with %d points") % (awarded_user, points) }
\ No newline at end of file
+
+        extra = dict(message=request.POST.get('message', ''), awarding_user=request.user.id, value=points)
+
+        # We take points from the awarding user
+        BonusRepAction(user=request.user, extra=extra).save(data=dict(value=-points, affected=user))
+
+        # And give them to the awarded one
+        BonusRepAction(user=request.user, extra=extra).save(data=dict(value=points, affected=awarded_user))
+
+        return { 'message' : _("You have awarded %s with %d points") % (awarded_user, points) }