captcha registry entry and vocabulary added.
svn path=/plone.app.discussion/trunk/; revision=28679
This commit is contained in:
@@ -7,21 +7,23 @@ from zope import interface, schema
|
||||
from zope.annotation import factory
|
||||
from zope.annotation.attribute import AttributeAnnotations
|
||||
|
||||
from zope.component import adapts, provideAdapter
|
||||
|
||||
from zope.component import adapts, provideAdapter, queryUtility
|
||||
from zope.publisher.interfaces.browser import IDefaultBrowserLayer
|
||||
|
||||
from zope.interface import Interface, implements
|
||||
|
||||
from plone.registry.interfaces import IRegistry
|
||||
|
||||
from plone.z3cform.fieldsets import extensible
|
||||
from plone.z3cform.fieldsets.interfaces import IFormExtender
|
||||
|
||||
from plone.app.discussion.comment import Comment
|
||||
from plone.app.discussion.browser.comments import CommentForm
|
||||
from plone.app.discussion.comment import Comment
|
||||
from plone.app.discussion.interfaces import IDiscussionSettings
|
||||
|
||||
class ICaptcha(Interface):
|
||||
captcha = schema.TextLine(title=u"Type the word 'human' in all capital letters.",
|
||||
required=False)
|
||||
captcha = schema.TextLine(title=u"Captcha",
|
||||
required=True)
|
||||
|
||||
class Captcha(Persistent):
|
||||
interface.implements(ICaptcha)
|
||||
@@ -40,6 +42,15 @@ class CaptchaExtender(extensible.FormExtender):
|
||||
self.request = request
|
||||
self.form = form
|
||||
|
||||
registry = queryUtility(IRegistry)
|
||||
settings = registry.forInterface(IDiscussionSettings)
|
||||
self.captcha = settings.captcha
|
||||
|
||||
def update(self):
|
||||
# Add all fields from the captcha interface
|
||||
self.add(ICaptcha, prefix="extra")
|
||||
if self.captcha != 'disabled':
|
||||
# Add all fields from the captcha interface
|
||||
self.add(ICaptcha, prefix="")
|
||||
if self.captcha == 'captcha':
|
||||
self.form.fields['captcha'].widgetFactory = CaptchaFieldWidget
|
||||
elif self.captcha == 'recaptcha':
|
||||
self.form.fields['captcha'].widgetFactory = ReCaptchaFieldWidget
|
||||
Reference in New Issue
Block a user