Captcha plugin support for collective.z3cform.norobots added.
svn path=/plone.app.discussion/trunk/; revision=39848
This commit is contained in:
parent
2aaf74ddd3
commit
3d594a934d
@ -4,6 +4,9 @@ Changelog
|
||||
1.0b7 (unreleased)
|
||||
------------------
|
||||
|
||||
* Captcha plugin support for collective.z3cform.norobots added.
|
||||
[]
|
||||
|
||||
* Store dates in utc and not in local time. Display local time
|
||||
[do3cc]
|
||||
|
||||
|
@ -67,6 +67,9 @@ class CaptchaExtender(extensible.FormExtender):
|
||||
elif self.captcha == 'recaptcha':
|
||||
from plone.formwidget.recaptcha import ReCaptchaFieldWidget
|
||||
self.form.fields['captcha'].widgetFactory = ReCaptchaFieldWidget
|
||||
elif self.captcha == 'norobots':
|
||||
from collective.z3cform.norobots import NorobotsFieldWidget
|
||||
self.form.fields['captcha'].widgetFactory = NorobotsFieldWidget
|
||||
else:
|
||||
self.form.fields['captcha'].mode = interfaces.HIDDEN_MODE
|
||||
|
||||
|
@ -44,7 +44,7 @@ class CaptchaValidator(validator.SimpleFieldValidator):
|
||||
registry = queryUtility(IRegistry)
|
||||
settings = registry.forInterface(IDiscussionSettings)
|
||||
|
||||
if settings.captcha == 'captcha' or settings.captcha == 'recaptcha':
|
||||
if settings.captcha in ('captcha', 'recaptcha', 'norobots'):
|
||||
captcha = getMultiAdapter((aq_inner(self.context), self.request),
|
||||
name=settings.captcha)
|
||||
if not captcha.verify(input=value):
|
||||
|
@ -58,8 +58,9 @@ class IDiscussionSettings(Interface):
|
||||
description=_(u"help_captcha",
|
||||
default=u"Use this setting to enable or disable Captcha "
|
||||
"validation for comments. Install "
|
||||
"plone.formwidget.captcha or "
|
||||
"plone.formwidget.recaptcha if there are no options "
|
||||
"plone.formwidget.captcha, "
|
||||
"plone.formwidget.recaptcha, collective.akismet, or "
|
||||
"collective.z3cform.norobots if there are no options "
|
||||
"available."),
|
||||
required=True,
|
||||
default='disabled',
|
||||
|
@ -25,6 +25,13 @@ try:
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
HAS_NOROBOTS = False
|
||||
try:
|
||||
import collective.z3cform.norobots
|
||||
HAS_NOROBOTS = True
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
||||
def captcha_vocabulary(context):
|
||||
"""Vocabulary with all available captcha implementations.
|
||||
@ -55,6 +62,14 @@ def captcha_vocabulary(context):
|
||||
token='akismet',
|
||||
title='Akismet'))
|
||||
|
||||
|
||||
if HAS_NOROBOTS:
|
||||
terms.append(
|
||||
SimpleTerm(
|
||||
value='norobots',
|
||||
token='norobots',
|
||||
title='Norobots'))
|
||||
|
||||
return SimpleVocabulary(terms)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user