diff options
Diffstat (limited to 'askbot/views/commands.py')
-rw-r--r-- | askbot/views/commands.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/askbot/views/commands.py b/askbot/views/commands.py index 5b7e8f18..04d4ef1b 100644 --- a/askbot/views/commands.py +++ b/askbot/views/commands.py @@ -35,7 +35,6 @@ def process_vote(user = None, vote_direction = None, post = None): also in the future make keys in response data be more meaningful right now they are kind of cryptic - "status", "count" """ - if user.is_anonymous(): raise exceptions.PermissionDenied(_('anonymous users cannot vote')) @@ -536,6 +535,25 @@ def swap_question_with_answer(request): } raise Http404 +@decorators.ajax_only +@decorators.post_only +def upvote_comment(request): + if request.user.is_anonymous(): + raise exceptions.PermissionDenied(_('Please sign in to vote')) + form = forms.VoteForm(request.POST) + if form.is_valid(): + comment_id = form.cleaned_data['post_id'] + cancel_vote = form.cleaned_data['cancel_vote'] + comment = models.Comment.objects.get(id = comment_id) + process_vote( + post = comment, + vote_direction = 'up', + user = request.user + ) + else: + raise ValueError + return {'score': comment.score} + #askbot-user communication system def read_message(request):#marks message a read if request.method == "POST": |