From b479038b4ae7b33b65bec9b5d5c5493ddc604090 Mon Sep 17 00:00:00 2001 From: jordan Date: Tue, 15 Mar 2011 14:38:14 +0000 Subject: [PATCH] #OSQA-388, connecting the award_points command to the BonusRepAction. We take the points from the current user and give them to the awarded one. git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@843 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- forum/views/commands.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/forum/views/commands.py b/forum/views/commands.py index bd8e373..0708f63 100644 --- a/forum/views/commands.py +++ b/forum/views/commands.py @@ -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) } -- 2.39.5