X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/87e592dc4c9e0321635350da8c9f1624554a604f..3fcef4ec7d2509284a43a2325ae2341d5553ab35:/forum/views/commands.py?ds=sidebyside diff --git a/forum/views/commands.py b/forum/views/commands.py index 452d57d..6220bc2 100644 --- a/forum/views/commands.py +++ b/forum/views/commands.py @@ -1,5 +1,5 @@ import datetime -from django.conf import settings +from forum import settings from django.core.exceptions import ObjectDoesNotExist from django.utils import simplejson from django.http import HttpResponse, HttpResponseRedirect, HttpResponseForbidden @@ -11,6 +11,7 @@ from forum.actions import * from django.core.urlresolvers import reverse from django.contrib.auth.decorators import login_required from forum.utils.decorators import ajax_method, ajax_login_required +from forum.modules.decorators import decoratable from decorators import command, CommandException from forum import settings import logging @@ -18,53 +19,31 @@ import logging class NotEnoughRepPointsException(CommandException): def __init__(self, action): super(NotEnoughRepPointsException, self).__init__( - _(""" - Sorry, but you don't have enough reputation points to %(action)s.
- Please check the faq - """ % {'action': action, 'faq_url': reverse('faq')}) + _("""Sorry, but you don't have enough reputation points to %(action)s.
Please check the faq""" % {'action': action, 'faq_url': reverse('faq')}) ) class CannotDoOnOwnException(CommandException): def __init__(self, action): super(CannotDoOnOwnException, self).__init__( - _(""" - Sorry but you cannot %(action)s your own post.
- Please check the faq - """ % {'action': action, 'faq_url': reverse('faq')}) + _("""Sorry but you cannot %(action)s your own post.
Please check the faq""" % {'action': action, 'faq_url': reverse('faq')}) ) class AnonymousNotAllowedException(CommandException): def __init__(self, action): super(AnonymousNotAllowedException, self).__init__( - _(""" - Sorry but anonymous users cannot %(action)s.
- Please login or create an account here. - """ % {'action': action, 'signin_url': reverse('auth_signin')}) - ) - -class SpamNotAllowedException(CommandException): - def __init__(self, action = "comment"): - super(SpamNotAllowedException, self).__init__( - _("""Your %s has been marked as spam.""" % action) + _("""Sorry but anonymous users cannot %(action)s.
Please login or create an account here.""" % {'action': action, 'signin_url': reverse('auth_signin')}) ) class NotEnoughLeftException(CommandException): def __init__(self, action, limit): super(NotEnoughLeftException, self).__init__( - _(""" - Sorry, but you don't have enough %(action)s left for today..
- The limit is %(limit)s per day..
- Please check the faq - """ % {'action': action, 'limit': limit, 'faq_url': reverse('faq')}) + _("""Sorry, but you don't have enough %(action)s left for today..
The limit is %(limit)s per day..
Please check the faq""" % {'action': action, 'limit': limit, 'faq_url': reverse('faq')}) ) class CannotDoubleActionException(CommandException): def __init__(self, action): super(CannotDoubleActionException, self).__init__( - _(""" - Sorry, but you cannot %(action)s twice the same post.
- Please check the faq - """ % {'action': action, 'faq_url': reverse('faq')}) + _("""Sorry, but you cannot %(action)s twice the same post.
Please check the faq""" % {'action': action, 'faq_url': reverse('faq')}) ) @@ -231,6 +210,7 @@ def mark_favorite(request, id): } } +@decoratable @command def comment(request, id): post = get_object_or_404(Node, id=id) @@ -253,17 +233,6 @@ def comment(request, id): if len(comment_text) > settings.FORM_MAX_COMMENT_BODY: raise CommandException(_("No more than %d characters on comment body.") % settings.FORM_MAX_COMMENT_BODY) - data = { - "user_ip":request.META["REMOTE_ADDR"], - "user_agent":request.environ['HTTP_USER_AGENT'], - "comment_author":request.user.username, - "comment_author_email":request.user.email, - "comment_author_url":request.user.website, - "comment":comment_text - } - if Node.isSpam(comment_text, data): - raise SpamNotAllowedException() - if 'id' in request.POST: comment = get_object_or_404(Comment, id=request.POST['id'])