X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/8814fb6f8c8476f673102c1ebe7b5b2d3cf7275a..7be81dfc799101c3d7e646d76b07ac30fc39bf61:/forum_modules/akismet/startup.py diff --git a/forum_modules/akismet/startup.py b/forum_modules/akismet/startup.py index d587ea1..2387e05 100644 --- a/forum_modules/akismet/startup.py +++ b/forum_modules/akismet/startup.py @@ -1,13 +1,18 @@ +import json +import loggin + from django.utils.translation import ugettext as _ from django.http import HttpResponse, HttpResponseRedirect -from django.utils import simplejson +from django.template import RequestContext from django.utils.encoding import smart_str from django.shortcuts import render_to_response from forum.modules import decorate from forum import views from lib.akismet import Akismet from forum.settings import APP_URL, OSQA_VERSION -from settings import WORDPRESS_API_KEY, REP_FOR_NO_SPAM_CHECK, RECAPTCHA_PUB_KEY, RECAPTCHA_PRIV_KEY + +from settings import WORDPRESS_API_KEY, REP_FOR_NO_SPAM_CHECK + from forum.models.user import User from forum.forms.general import SimpleCaptchaForm @@ -47,20 +52,21 @@ def check_spam(param, comment_type): 'success': False, 'error_message': _("Sorry, but akismet thinks your %s is spam.") % comment_type } - return HttpResponse(simplejson.dumps(response), mimetype="application/json") + return HttpResponse(json.dumps(response), mimetype="application/json") else: captcha_checked = False - - if RECAPTCHA_PUB_KEY and RECAPTCHA_PRIV_KEY: - if captcha_form.is_valid(): + try: + if captcha_form.is_valid() and 'recaptcha' in captcha_form.fields.keys(): captcha_checked = True - + except: + pass + if not captcha_checked: return render_to_response('modules/akismet/foundspam.html', { 'action_name': comment_type, 'post_data' : post_data, 'captcha_form' : captcha_form, - }) + }, RequestContext(request)) return origin(request, *args, **kwargs)