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