X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/3b2f9ebad3131bb86045f3ac1d3b4f43b6d78398..1eb51aa3f7a7add93f837456759d453288e6a454:/forum/views/commands.py?ds=sidebyside
diff --git a/forum/views/commands.py b/forum/views/commands.py
index 89f3fb8..ee62af4 100644
--- a/forum/views/commands.py
+++ b/forum/views/commands.py
@@ -43,7 +43,7 @@ class AnonymousNotAllowedException(Exception):
class NotEnoughLeftException(Exception):
def __init__(self, action, limit):
- super(NotEnoughRepPointsException, self).__init__(
+ super(NotEnoughLeftException, self).__init__(
_("""
Sorry, but you don't have enough %(action)s left for today..
The limit is %(limit)s per day..
@@ -63,7 +63,7 @@ class CannotDoubleActionException(Exception):
@command
def vote_post(request, id, vote_type):
- post = get_object_or_404(Node, id=id)
+ post = get_object_or_404(Node, id=id).leaf
vote_score = vote_type == 'up' and 1 or -1
user = request.user
@@ -107,7 +107,7 @@ def vote_post(request, id, vote_type):
votes_left = int(settings.MAX_VOTES_PER_DAY) - user_vote_count_today + (vote_type == 'none' and -1 or 1)
if int(settings.START_WARN_VOTES_LEFT) >= votes_left:
- response['message'] = _("You have %(nvotes) %(tvotes) left today.") % \
+ response['message'] = _("You have %(nvotes)s %(tvotes)s left today.") % \
{'nvotes': votes_left, 'tvotes': ungettext('vote', 'votes', votes_left)}
return response
@@ -232,17 +232,16 @@ def comment(request, id):
if not user.can_comment(post):
raise NotEnoughRepPointsException( _('comment'))
- comment = Comment(user=user, node=post)
+ comment = Comment(parent=post)
comment_text = request.POST.get('comment', '').strip()
if not len(comment_text):
raise Exception(_("Comment is empty"))
- comment.comment=comment_text
- comment.save()
+ comment.create_revision(user, body=comment_text)
- if comment._is_new:
+ if comment.active_revision.revision == 1:
return {
'commands': {
'insert_comment': [