- Fixed "global name 'WrongCaptchaCode' is not defined" if norobots captcha,
but no other validation package is installed. svn path=/plone.app.discussion/trunk/; revision=40574
This commit is contained in:
parent
f7ed357a83
commit
18e92f7a85
@ -4,6 +4,10 @@ Changelog
|
||||
1.0b10 (unreleased)
|
||||
-------------------
|
||||
|
||||
- Fixed "global name 'WrongCaptchaCode' is not defined" if norobots captcha,
|
||||
but no other validation package is installed.
|
||||
[naro]
|
||||
|
||||
- Check if there is a 'pending' review state in the current workflow for
|
||||
comments instead of just checking for the 'comment_review_workflow'. This
|
||||
allows integrators to use a custom review workflow. This fixes
|
||||
|
@ -21,6 +21,11 @@ from plone.app.discussion.interfaces import ICaptcha
|
||||
from plone.app.discussion.interfaces import IDiscussionSettings
|
||||
from plone.app.discussion.interfaces import IDiscussionLayer
|
||||
|
||||
try:
|
||||
from collective.z3cform.norobots.validator import WrongNorobotsAnswer
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
try:
|
||||
from plone.formwidget.captcha.validator import WrongCaptchaCode
|
||||
except ImportError:
|
||||
@ -31,7 +36,6 @@ try:
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
||||
class CaptchaValidator(validator.SimpleFieldValidator):
|
||||
implements(IValidator)
|
||||
adapts(Interface, IDiscussionLayer, Interface, IField, Interface)
|
||||
@ -48,6 +52,9 @@ class CaptchaValidator(validator.SimpleFieldValidator):
|
||||
captcha = getMultiAdapter((aq_inner(self.context), self.request),
|
||||
name=settings.captcha)
|
||||
if not captcha.verify(input=value):
|
||||
if settings.captcha == 'norobots':
|
||||
raise WrongNorobotsAnswer
|
||||
else:
|
||||
raise WrongCaptchaCode
|
||||
else:
|
||||
return True
|
||||
|
Loading…
Reference in New Issue
Block a user