Commit cd8779ee authored by Noe Nieto's avatar Noe Nieto 💬

Config Option to disable CAPTCHA on register form (liberty/ldh_middleware#73)

parent 2457e673
......@@ -32,11 +32,6 @@ class CartRegistrationForm(RegistrationForm):
field_order = ('username', 'email', 'password1', 'password2', 'captcha')
captcha = CaptchaField(
label=_('Please solve this sum'),
help_text=_('Prove you are not a robot. Solve this addition, subtraction or multiplication problem.'),
)
email = forms.EmailField(
label=_('Recovery email address'),
help_text=_('Enter an email address were we can send you recovery information.'),
......@@ -45,12 +40,23 @@ class CartRegistrationForm(RegistrationForm):
],
)
class CartRegistrationFormWithCaptcha(CartRegistrationForm):
captcha = CaptchaField(
label=_('Please solve this sum'),
help_text=_('Prove you are not a robot. Solve this addition, subtraction or multiplication problem.'),
)
class CartRegistrationView(RegistrationView):
form_class = CartRegistrationForm
form_class = CartRegistrationFormWithCaptcha
template_name = 'cart/registration_form.html'
reward = None
def get_form_class(self):
if settings.DEBUG_REMOVE_CAPTCHA:
return CartRegistrationForm
return self.form_class
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['DEBUG_REGISTER_STATUS'] = settings.DEBUG_REGISTER_STATUS
......
......@@ -14,6 +14,7 @@ DEBUG_REGISTER_STATUS = True
DEBUG_SKIP_ACTIVATION_COMMAND=True
DEBUG_SKIP_VALIDATE_ON_AUTHENTICATION = False
DEBUG_LOCAL_MAIL = False
DEBUG_REMOVE_CAPTCHA = False
# change to false after initial setup
ALLOWED_HOSTS=localhost
STATIC_ROOT=/var/opt/purist/middleware/static
......
......@@ -42,9 +42,6 @@ class RegistrationForm(BaseRegistrationForm):
strip=False,
help_text=_("Enter the same passphrase as before, for verification."),
)
captcha = CaptchaField(
label=_('Are you a robot?')
)
def __init__(self, *args, **kwargs):
super(RegistrationForm, self).__init__(*args, **kwargs)
......
......@@ -37,6 +37,9 @@ DEBUG_SKIP_ACTIVATION_COMMAND = config("DEBUG_SKIP_ACTIVATION_COMMAND", cast=boo
DEBUG_SKIP_VALIDATE_ON_AUTHENTICATION = config("DEBUG_SKIP_VALIDATE_ON_AUTHENTICATION", cast=bool)
DEBUG_REGISTER_STATUS = config("DEBUG_REGISTER_STATUS", cast=bool)
DEBUG_LOCAL_MAIL = config("DEBUG_LOCAL_MAIL", cast=bool)
DEBUG_REMOVE_CAPTCHA = config("DEBUG_REMOVE_CAPTCHA", cast=bool)
# Required if DEBUG is False
ALLOWED_HOSTS = config("ALLOWED_HOSTS", cast=Csv())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment