Skip to content

Latest commit

 

History

History
112 lines (75 loc) · 4.11 KB

README.rst

File metadata and controls

112 lines (75 loc) · 4.11 KB
https://travis-ci.org/springload/wagtail-django-recaptcha.svg?branch=master

Wagtail ReCaptcha

Wagtail forms with a ReCaptcha form field/widget integration app. Wagtail ReCaptcha provides an easy way to integrate the django-recaptcha field when using the Wagtail formbuilder.

Check out Awesome Wagtail for more awesome packages and resources from the Wagtail community.

Installation

  1. Install wagtailcaptcha via pip pip install wagtail-django-recaptcha or add wagtailcaptcha to your Python path.
  2. Add wagtailcaptcha to your INSTALLED_APPS setting.
  3. Config django-recaptcha as explained in here.

Usage

Field

The quickest way to add a captcha field to a Wagtail Form Page is to inherit from the two options provided, WagtailCaptchaForm or WagtailCaptchaEmailForm. The first options inherits from AbstractForm while the seconds does it from AbstractEmailForm. Either way your page is going to display a captcha field at the end of the form.

Example

from wagtail.wagtailforms.models import AbstractFormField
from wagtail.wagtailadmin.edit_handlers import FieldPanel, InlinePanel, MultiFieldPanel
from wagtail.wagtailcore.fields import RichTextField

from modelcluster.fields import ParentalKey

from wagtailcaptcha.models import WagtailCaptchaForm


class SubmitFormField(AbstractFormField):
    page = ParentalKey('SubmitFormPage', related_name='form_fields')


class SubmitFormPage(WagtailCaptchaForm):
    body = RichTextField(blank=True, help_text='Edit the content you want to see before the form.')
    thank_you_text = RichTextField(blank=True, help_text='Set the message users will see after submitting the form.')

    class Meta:
        verbose_name = "Form submission page"
        description = "Page with the form to submit"


SubmitFormPage.content_panels = [
    FieldPanel('title', classname="full title"),
    FieldPanel('body', classname="full"),
    FieldPanel('thank_you_text', classname="full"),
    InlinePanel(SubmitFormPage, 'form_fields', label="Form fields"),
    MultiFieldPanel([
        FieldPanel('to_address'),
        FieldPanel('from_address'),
        FieldPanel('subject'),
    ], "Email notification")
]

The captcha field can't be added from the admin UI but will appear in your frontend as the last of the form fields.

For a more thorough example, Made with Wagtail (github.com/springload/madewithwagtail) is an example of an open-source site using this module.

Development

Installation

Requirements: virtualenv, pyenv, twine
git clone [email protected]:springload/wagtail-django-recaptcha.git
cd wagtail-django-recaptcha/
virtualenv .venv
source ./.venv/bin/activate
make init

Commands

make help            # See what commands are available.
make lint            # Lint the project.
make clean-pyc       # Remove Python file artifacts.
make publish         # Publishes a new version to pypi.

Releases