Поле Captcha в регистрационной форме пользователя plone

Мне нужно поле с капчей в форме регистрации пользователя plone по умолчанию (@@register).


person GhitaB    schedule 08.10.2015    source источник


Ответы (1)


Решено с помощью https://plone.org/products/quintagroup.formlib.captcha

from mypackage import myMessageFactory as _
from quintagroup.formlib.captcha import Captcha
from quintagroup.formlib.captcha import CaptchaWidget
from plone.app.users.browser.register import RegistrationForm
from zope.interface import Interface
from zope.formlib import form


class ICaptchaSchema(Interface):
    captcha = Captcha(
        title=_(u'Prevent spam'),
        description=_(
            u'Type the text in the picture.'
        ),
    )


class CustomRegistrationForm(RegistrationForm):
    """ Custom registration form
    """

    @property
    def form_fields(self):
        fields = super(CustomRegistrationForm, self).form_fields
        fields += form.Fields(ICaptchaSchema)
        fields['captcha'].custom_widget = CaptchaWidget

        return fields
person GhitaB    schedule 08.10.2015