]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/views/commands.py
If you're a superuser viweing a user auth settings, don't present the option to add...
[osqa.git] / forum / views / commands.py
index 8591930c7ae2233543ae7c3ac15d1466fbaf6cc1..d8c4231b46764847af62b981c71c7d1d2003054d 100644 (file)
@@ -1,5 +1,5 @@
 import datetime
 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
 from django.core.exceptions import ObjectDoesNotExist
 from django.utils import simplejson
 from django.http import HttpResponse, HttpResponseRedirect, HttpResponseForbidden
@@ -7,11 +7,11 @@ from django.shortcuts import get_object_or_404, render_to_response
 from django.utils.translation import ungettext, ugettext as _
 from django.template import RequestContext
 from forum.models import *
 from django.utils.translation import ungettext, ugettext as _
 from django.template import RequestContext
 from forum.models import *
-from forum.forms import CloseForm
 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.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
 from decorators import command, CommandException
 from forum import settings
 import logging
@@ -43,12 +43,6 @@ class AnonymousNotAllowedException(CommandException):
             """ % {'action': action, 'signin_url': reverse('auth_signin')})
         )
 
             """ % {'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)
-        )
-
 class NotEnoughLeftException(CommandException):
     def __init__(self, action, limit):
         super(NotEnoughLeftException, self).__init__(
 class NotEnoughLeftException(CommandException):
     def __init__(self, action, limit):
         super(NotEnoughLeftException, self).__init__(
@@ -232,6 +226,7 @@ def mark_favorite(request, id):
         }
     }
 
         }
     }
 
+@decoratable
 @command
 def comment(request, id):
     post = get_object_or_404(Node, id=id)
 @command
 def comment(request, id):
     post = get_object_or_404(Node, id=id)
@@ -254,17 +249,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)
 
     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'])
 
     if 'id' in request.POST:
         comment = get_object_or_404(Comment, id=request.POST['id'])