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 z3c.form import validator
|
||||
from z3c.form import interfaces, validator
|
||||
from z3c.form.field import Fields
|
||||
|
||||
from zope import interface, schema
|
||||
@ -70,4 +70,5 @@ class CaptchaExtender(extensible.FormExtender):
|
||||
elif self.captcha == 'recaptcha':
|
||||
from plone.formwidget.recaptcha import 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 _
|
||||
|
||||
HAS_CAPTCHA=False
|
||||
HAS_CAPTCHA = False
|
||||
try:
|
||||
import plone.formwidget.captcha
|
||||
HAS_CAPTCHA = True
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
HAS_RECAPTCHA=False
|
||||
HAS_RECAPTCHA = False
|
||||
try:
|
||||
import plone.formwidget.recaptcha
|
||||
HAS_RECAPTCHA = True
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
HAS_AKISMET = False
|
||||
try:
|
||||
from akismet import Akismet, AkismetError
|
||||
HAS_AKISMET = True
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
||||
def captcha_vocabulary(context):
|
||||
"""Vocabulary with all available captcha implementations.
|
||||
"""
|
||||
@ -41,6 +49,13 @@ def captcha_vocabulary(context):
|
||||
value='recaptcha',
|
||||
token='recaptcha',
|
||||
title='ReCaptcha'))
|
||||
if HAS_AKISMET:
|
||||
terms.append(
|
||||
zope.schema.vocabulary.SimpleTerm(
|
||||
value='akismet',
|
||||
token='akismet',
|
||||
title='Akismet'))
|
||||
|
||||
return zope.schema.vocabulary.SimpleVocabulary(terms)
|
||||
|
||||
interface.alsoProvides(captcha_vocabulary,
|
||||
|
Loading…
Reference in New Issue
Block a user