]> git.openstreetmap.org Git - osqa.git/commitdiff
OSQA-516, bugfix for the Akismet Module. There was problem with the loading of the...
authorjordan <jordan@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Tue, 15 Feb 2011 17:38:22 +0000 (17:38 +0000)
committerjordan <jordan@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Tue, 15 Feb 2011 17:38:22 +0000 (17:38 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@768 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum/forms/general.py
forum_modules/akismet/startup.py
forum_modules/akismet/templates/foundspam.html

index 4b1133e0f0ce6e811ee688565534ef45951cc4b3..e0348a8710b09f68fbc6c27822b1497bb16b45a9 100644 (file)
@@ -7,6 +7,7 @@ from django.http import str_to_unicode
 from forum.models import User
 from forum.modules import call_all_handlers
 import urllib
+import logging
 
 DEFAULT_NEXT = getattr(settings, 'APP_BASE_URL')
 def clean_next(next):
@@ -156,7 +157,11 @@ class SetPasswordForm(forms.Form):
             return self.cleaned_data['password2']
 
 class SimpleCaptchaForm(forms.Form):
+    fields = {}
+
     def __init__(self, *args, **kwargs):
+        super(SimpleCaptchaForm, self).__init__(*args, **kwargs)
+
         spam_fields = call_all_handlers('create_anti_spam_field')
         if spam_fields:
             spam_fields = dict(spam_fields)
@@ -166,4 +171,3 @@ class SimpleCaptchaForm(forms.Form):
             self._anti_spam_fields = spam_fields.keys()
         else:
             self._anti_spam_fields = []
-
index d587ea1c00d9f6adefb5da9c767bae7a44912e34..2107bbbe8f3aa981d8700217f799afd9013e8e3b 100644 (file)
@@ -1,5 +1,6 @@
 from django.utils.translation import ugettext as _
 from django.http import HttpResponse, HttpResponseRedirect
+from django.template import RequestContext
 from django.utils import simplejson
 from django.utils.encoding import smart_str
 from django.shortcuts import render_to_response
@@ -7,11 +8,14 @@ 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
 
 import settings
+import logging
 
 def can_bypass_spam_check(user):
     return user.is_authenticated and (user.is_superuser or user.is_staff or cmp(int(user.reputation), REP_FOR_NO_SPAM_CHECK) > 0)
@@ -50,17 +54,18 @@ def check_spam(param, comment_type):
                     return HttpResponse(simplejson.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)
 
index 6b203c00a7ffd9f24c131184a638edac6314f9f2..77251c72de12238bd71075c17e3ae326d1f30eda 100644 (file)
@@ -12,6 +12,7 @@ We're sorry, but Akismet believes your {{ action_name }} is spam.<br />
 If you believe this is an error, please contact the forum administrator.
 {% endblocktrans %}
 
+{% if captcha_form.recaptcha %}
 <form action="." method="post">
 <table>
        <tr>
@@ -19,7 +20,7 @@ If you believe this is an error, please contact the forum administrator.
                {% for post_item in post_data.items %}
                <input type="hidden" name="{{ post_item.0 }}" value="{{ post_item.1 }}" />
                {% endfor %}
-               
+
                {{ captcha_form.recaptcha }}
                
                </td>
@@ -29,6 +30,7 @@ If you believe this is an error, please contact the forum administrator.
        </tr>
 </table>
 </form>
+{% endif %}
 
 </div>
 {% endblock %}