do not make a captcha check when captcha is disabled; this fixes the non-captcha comment form.
svn path=/plone.app.discussion/trunk/; revision=28790
This commit is contained in:
parent
ce30a1b594
commit
2a1ae7dc62
@ -32,7 +32,9 @@ from plone.registry.interfaces import IRegistry
|
|||||||
from plone.app.layout.viewlets.common import ViewletBase
|
from plone.app.layout.viewlets.common import ViewletBase
|
||||||
|
|
||||||
from plone.app.discussion.comment import Comment, CommentFactory
|
from plone.app.discussion.comment import Comment, CommentFactory
|
||||||
from plone.app.discussion.interfaces import IConversation, IComment, IReplies, IDiscussionSettings
|
from plone.app.discussion.interfaces import IConversation, IComment, IReplies, IDiscussionSettings, ICaptcha
|
||||||
|
|
||||||
|
from plone.formwidget.captcha.validator import CaptchaValidator
|
||||||
|
|
||||||
from plone.z3cform import layout, z2
|
from plone.z3cform import layout, z2
|
||||||
from plone.z3cform.fieldsets import extensible
|
from plone.z3cform.fieldsets import extensible
|
||||||
@ -77,14 +79,15 @@ class CommentForm(extensible.ExtensibleForm, form.Form):
|
|||||||
def handleComment(self, action):
|
def handleComment(self, action):
|
||||||
data, errors = self.extractData()
|
data, errors = self.extractData()
|
||||||
|
|
||||||
|
registry = queryUtility(IRegistry)
|
||||||
|
settings = registry.forInterface(IDiscussionSettings)
|
||||||
|
if settings.captcha != 'disabled':
|
||||||
|
# Check captcha only if it is not disabled
|
||||||
if data.has_key('captcha'):
|
if data.has_key('captcha'):
|
||||||
from plone.formwidget.captcha.validator import CaptchaValidator
|
# Check captcha only if there is a value, otherwise
|
||||||
from plone.app.discussion.interfaces import ICaptcha
|
# the default "required" validator is sufficient.
|
||||||
# Verify the user input against the captcha
|
|
||||||
captcha = CaptchaValidator(self.context, self.request, None, ICaptcha['captcha'], None)
|
captcha = CaptchaValidator(self.context, self.request, None, ICaptcha['captcha'], None)
|
||||||
if data.has_key('subject') and captcha.validate(data['captcha']):
|
captcha.validate(data['captcha'])
|
||||||
# if captcha validation passes, print the subject
|
|
||||||
print data['subject']
|
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user