- 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)
|
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
|
- Check if there is a 'pending' review state in the current workflow for
|
||||||
comments instead of just checking for the 'comment_review_workflow'. This
|
comments instead of just checking for the 'comment_review_workflow'. This
|
||||||
allows integrators to use a custom review workflow. This fixes
|
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 IDiscussionSettings
|
||||||
from plone.app.discussion.interfaces import IDiscussionLayer
|
from plone.app.discussion.interfaces import IDiscussionLayer
|
||||||
|
|
||||||
|
try:
|
||||||
|
from collective.z3cform.norobots.validator import WrongNorobotsAnswer
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from plone.formwidget.captcha.validator import WrongCaptchaCode
|
from plone.formwidget.captcha.validator import WrongCaptchaCode
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@ -31,7 +36,6 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class CaptchaValidator(validator.SimpleFieldValidator):
|
class CaptchaValidator(validator.SimpleFieldValidator):
|
||||||
implements(IValidator)
|
implements(IValidator)
|
||||||
adapts(Interface, IDiscussionLayer, Interface, IField, Interface)
|
adapts(Interface, IDiscussionLayer, Interface, IField, Interface)
|
||||||
@ -48,7 +52,10 @@ class CaptchaValidator(validator.SimpleFieldValidator):
|
|||||||
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):
|
||||||
raise WrongCaptchaCode
|
if settings.captcha == 'norobots':
|
||||||
|
raise WrongNorobotsAnswer
|
||||||
|
else:
|
||||||
|
raise WrongCaptchaCode
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user