A simple recaptcha field for Wagtail Form Pages.
Project description
Wagtail ReCaptcha
Wagtail forms with a ReCaptcha form field/widget integration app.
wagtail-django-captcha provides an easy way to integrate the django-recaptcha field when using the Wagtail formbuilder.
Installation
Install or add wagtailcaptcha to your Python path.
Add wagtailcaptcha to your INSTALLED_APPS setting.
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.
Development
Installation
Requirements: virtualenv, pyenv, twine
git clone git@github.com: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
Update the changelog.
Update the version number in setup.py.
git release x.y
make publish (confirm, and enter your password)
Go to https://pypi-hypernode.com/pypi/wagtail-django-recaptcha and check that all is well
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Hashes for wagtail-django-recaptcha-0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 295256f09ef9a733855446f4020c3e82445ae04030f335d628a72911c51f4ea2 |
|
MD5 | 76e86c1d7d9c2d1c0d5fc60f645f0b17 |
|
BLAKE2b-256 | 1144bbd40584a2c3af71e885278eabc75637b1cc61ef12402b4c02c0a7b69f4e |