Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Thank you for contributing! Please follow the guidelines below to submit your
pull request. Additional details are available in our
Contributor Guide.
Description of change
I added a simple captcha, based on comments in issue #420. @vsalvino mentioned he found a good open-source captcha package to integrate (https://django-simple-captcha.readthedocs.io/en/latest/index.html) and I found wagtail variants in the form of
https://github.com/acarasimon96/wagtail-django-simple-captcha
and
https://github.com/springload/wagtail-django-recaptcha
The latter has implemented the bulk of the work, the former just makes it so that it works with simple-captcha rather than recaptcha.
I saw no easy way to import those existing package to integrate with coderedcms and rather opted to utilize their code directly (in the case of the CodeRedFormBuilder we could subclass it from WagtailCaptchaFormBuilder but I'm not sure if this is as trivial for the code in the CoderedFormPage class in the page_models file due to the fact that process_form_submission has been redefined somewhere earlier and because it does not subclass AbstractForm).
I have clearly marked which functions I am talking about but I would like input on how you prefer to reference their source code.
The functionality looks as follows:
and can be toggled via the spam_protection checkbox under settings.
Documentation
I added a small part that says the captcha will be created when toggling the spam_protection checkbox.
Tests
Due to not importing the packages themselves directly, we would need to copy the tests as well, but the structure of their testapp looks a bit different from what is being done in CodeRedCMS so I'm not sure to what extent I should copy it.