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.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.modules.decorators import decoratable
from decorators import command, CommandException
from forum import settings
import logging
""" % {'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__(
}
}
+@decoratable
@command
def comment(request, id):
post = get_object_or_404(Node, id=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'])