Akismet spam protection plugin support added (collective.akismet).
svn path=/plone.app.discussion/trunk/; revision=37136
This commit is contained in:
parent
92766752c4
commit
926314ea49
@ -6,7 +6,7 @@ from persistent import Persistent
|
|||||||
|
|
||||||
from Products.CMFCore.utils import getToolByName
|
from Products.CMFCore.utils import getToolByName
|
||||||
|
|
||||||
from z3c.form import validator
|
from z3c.form import interfaces, validator
|
||||||
from z3c.form.field import Fields
|
from z3c.form.field import Fields
|
||||||
|
|
||||||
from zope import interface, schema
|
from zope import interface, schema
|
||||||
@ -70,4 +70,5 @@ class CaptchaExtender(extensible.FormExtender):
|
|||||||
elif self.captcha == 'recaptcha':
|
elif self.captcha == 'recaptcha':
|
||||||
from plone.formwidget.recaptcha import ReCaptchaFieldWidget
|
from plone.formwidget.recaptcha import ReCaptchaFieldWidget
|
||||||
self.form.fields['captcha'].widgetFactory = ReCaptchaFieldWidget
|
self.form.fields['captcha'].widgetFactory = ReCaptchaFieldWidget
|
||||||
|
elif self.captcha == 'akismet':
|
||||||
|
self.form.fields['captcha'].mode = interfaces.HIDDEN_MODE
|
||||||
|
@ -5,20 +5,28 @@ import zope.schema.vocabulary
|
|||||||
|
|
||||||
from plone.app.discussion.interfaces import _
|
from plone.app.discussion.interfaces import _
|
||||||
|
|
||||||
HAS_CAPTCHA=False
|
HAS_CAPTCHA = False
|
||||||
try:
|
try:
|
||||||
import plone.formwidget.captcha
|
import plone.formwidget.captcha
|
||||||
HAS_CAPTCHA = True
|
HAS_CAPTCHA = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
HAS_RECAPTCHA=False
|
HAS_RECAPTCHA = False
|
||||||
try:
|
try:
|
||||||
import plone.formwidget.recaptcha
|
import plone.formwidget.recaptcha
|
||||||
HAS_RECAPTCHA = True
|
HAS_RECAPTCHA = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
HAS_AKISMET = False
|
||||||
|
try:
|
||||||
|
from akismet import Akismet, AkismetError
|
||||||
|
HAS_AKISMET = True
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def captcha_vocabulary(context):
|
def captcha_vocabulary(context):
|
||||||
"""Vocabulary with all available captcha implementations.
|
"""Vocabulary with all available captcha implementations.
|
||||||
"""
|
"""
|
||||||
@ -41,6 +49,13 @@ def captcha_vocabulary(context):
|
|||||||
value='recaptcha',
|
value='recaptcha',
|
||||||
token='recaptcha',
|
token='recaptcha',
|
||||||
title='ReCaptcha'))
|
title='ReCaptcha'))
|
||||||
|
if HAS_AKISMET:
|
||||||
|
terms.append(
|
||||||
|
zope.schema.vocabulary.SimpleTerm(
|
||||||
|
value='akismet',
|
||||||
|
token='akismet',
|
||||||
|
title='Akismet'))
|
||||||
|
|
||||||
return zope.schema.vocabulary.SimpleVocabulary(terms)
|
return zope.schema.vocabulary.SimpleVocabulary(terms)
|
||||||
|
|
||||||
interface.alsoProvides(captcha_vocabulary,
|
interface.alsoProvides(captcha_vocabulary,
|
||||||
|
Loading…
Reference in New Issue
Block a user