source: products/quintagroup.plonecaptchas/trunk/quintagroup/plonecaptchas/browser/register.py

Last change on this file was 3160, checked in by vmaksymiv, 13 years ago

pep8fixes

  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 1.1 KB
Line 
1from zope.formlib import form
2from zope.interface import Interface
3from plone.app.users.browser.register import RegistrationForm
4
5from quintagroup.formlib.captcha import Captcha
6from quintagroup.formlib.captcha import CaptchaWidget
7
8from quintagroup.plonecaptchas import ProductMessageFactory as _
9
10
11class CaptchaSchema(Interface):
12    captcha = Captcha(
13        title=_(u'Type the code'),
14        description=_(u'Type the code from the picture shown below.'))
15
16
17class CaptchaRegistrationForm(RegistrationForm):
18    """Registration form with captacha."""
19
20    @property
21    def form_fields(self):
22        """Add captcha field to form_fields."""
23        ffields = super(CaptchaRegistrationForm, self).form_fields
24        if len(ffields):
25            ffields = ffields + form.Fields(CaptchaSchema)
26            # XXX: Because of raising ConfigurationConflictError when include
27            # configure.zcml slug of quintagroup.formlib.captcha, we must
28            # explicytly define custom CaptchaWidget widget for Captcha field.
29            ffields["captcha"].custom_widget = CaptchaWidget
30        return ffields
Note: See TracBrowser for help on using the repository browser.