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 | |
---|
1 | from zope.formlib import form |
---|
2 | from zope.interface import Interface |
---|
3 | from plone.app.users.browser.register import RegistrationForm |
---|
4 | |
---|
5 | from quintagroup.formlib.captcha import Captcha |
---|
6 | from quintagroup.formlib.captcha import CaptchaWidget |
---|
7 | |
---|
8 | from quintagroup.plonecaptchas import ProductMessageFactory as _ |
---|
9 | |
---|
10 | |
---|
11 | class CaptchaSchema(Interface): |
---|
12 | captcha = Captcha( |
---|
13 | title=_(u'Type the code'), |
---|
14 | description=_(u'Type the code from the picture shown below.')) |
---|
15 | |
---|
16 | |
---|
17 | class 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.