diff mbox series

[2/2] forms: Use a captcha on the registration form.

Message ID 20210227095911.6290-2-mail@cbaines.net
State Changes Requested
Headers show
Series [1/2] templates: Use form.as_table in registration template. | expand

Commit Message

Christopher Baines Feb. 27, 2021, 9:59 a.m. UTC
This should help avoid spam registration requests.
---
 patchwork/forms.py         | 3 +++
 patchwork/settings/base.py | 1 +
 2 files changed, 4 insertions(+)

Comments

Stephen Finucane Aug. 12, 2021, 4:34 p.m. UTC | #1
On Sat, 2021-02-27 at 09:59 +0000, Christopher Baines wrote:
> This should help avoid spam registration requests.
> ---
>  patchwork/forms.py         | 3 +++
>  patchwork/settings/base.py | 1 +
>  2 files changed, 4 insertions(+)
> 
> diff --git a/patchwork/forms.py b/patchwork/forms.py
> index e06cfc1..f02bd29 100644
> --- a/patchwork/forms.py
> +++ b/patchwork/forms.py
> @@ -8,6 +8,8 @@ from django import forms
>  from django.db.models import Q
>  from django.db.utils import ProgrammingError
>  
> +from simplemathcaptcha.fields import MathCaptchaField
> +
>  from patchwork.models import Bundle
>  from patchwork.models import Patch
>  from patchwork.models import State
> @@ -27,6 +29,7 @@ class RegistrationForm(forms.Form):
>                                  label=u'Username')
>      password = forms.CharField(widget=forms.PasswordInput(),
>                                 label='Password')
> +    captcha = MathCaptchaField()
>  
>      def clean_username(self):
>          value = self.cleaned_data['username']
> diff --git a/patchwork/settings/base.py b/patchwork/settings/base.py
> index c1bb9b2..e18ee60 100644
> --- a/patchwork/settings/base.py
> +++ b/patchwork/settings/base.py
> @@ -21,6 +21,7 @@ INSTALLED_APPS = [
>      'django.contrib.sites',
>      'django.contrib.admin',
>      'django.contrib.staticfiles',
> +    'simplemathcaptcha',
>      'patchwork',
>  ]
>  

Long term, I think this is something we'll definitely enable by default.
However, it is an additional dependency which is something we have historically
avoided to keep people deploying this the old school way (i.e. not in
containers) happy. Could you make this optional like we do currently for the
REST Framework?

Thanks,
Stephen
diff mbox series

Patch

diff --git a/patchwork/forms.py b/patchwork/forms.py
index e06cfc1..f02bd29 100644
--- a/patchwork/forms.py
+++ b/patchwork/forms.py
@@ -8,6 +8,8 @@  from django import forms
 from django.db.models import Q
 from django.db.utils import ProgrammingError
 
+from simplemathcaptcha.fields import MathCaptchaField
+
 from patchwork.models import Bundle
 from patchwork.models import Patch
 from patchwork.models import State
@@ -27,6 +29,7 @@  class RegistrationForm(forms.Form):
                                 label=u'Username')
     password = forms.CharField(widget=forms.PasswordInput(),
                                label='Password')
+    captcha = MathCaptchaField()
 
     def clean_username(self):
         value = self.cleaned_data['username']
diff --git a/patchwork/settings/base.py b/patchwork/settings/base.py
index c1bb9b2..e18ee60 100644
--- a/patchwork/settings/base.py
+++ b/patchwork/settings/base.py
@@ -21,6 +21,7 @@  INSTALLED_APPS = [
     'django.contrib.sites',
     'django.contrib.admin',
     'django.contrib.staticfiles',
+    'simplemathcaptcha',
     'patchwork',
 ]