diff --git a/CHANGES.txt b/CHANGES.txt index a4c2a8f..30cc666 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -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 diff --git a/plone/app/discussion/browser/validator.py b/plone/app/discussion/browser/validator.py index 8a46bc7..8e38e6d 100644 --- a/plone/app/discussion/browser/validator.py +++ b/plone/app/discussion/browser/validator.py @@ -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,7 +52,10 @@ class CaptchaValidator(validator.SimpleFieldValidator): captcha = getMultiAdapter((aq_inner(self.context), self.request), name=settings.captcha) if not captcha.verify(input=value): - raise WrongCaptchaCode + if settings.captcha == 'norobots': + raise WrongNorobotsAnswer + else: + raise WrongCaptchaCode else: return True