From: Stephen Burrows Date: Mon, 13 Sep 2010 17:53:25 +0000 (-0400) Subject: Added recaptcha support to waldo registration form. X-Git-Tag: philo-0.9~32^2~7 X-Git-Url: http://git.ithinksw.org/philo.git/commitdiff_plain/be58b3e61477d8007fbd033ab758d30eb652d55e?hp=a8ca5f4d7033f91afa24acbcd015f24350ea0d26 Added recaptcha support to waldo registration form. --- diff --git a/contrib/waldo/forms.py b/contrib/waldo/forms.py index 4465a99..18c22a4 100644 --- a/contrib/waldo/forms.py +++ b/contrib/waldo/forms.py @@ -1,5 +1,6 @@ from datetime import date from django import forms +from django.conf import settings from django.contrib.auth.forms import AuthenticationForm, UserCreationForm from django.contrib.auth.models import User from django.core.exceptions import ValidationError @@ -19,6 +20,13 @@ class EmailInput(forms.TextInput): class RegistrationForm(UserCreationForm): email = forms.EmailField(widget=EmailInput) + try: + from recaptcha_django import ReCaptchaField + except ImportError: + pass + else: + if 'recaptcha_django.middleware.ReCaptchaMiddleware' in settings.MIDDLEWARE_CLASSES: + recaptcha = ReCaptchaField() def clean_username(self): username = self.cleaned_data['username'] diff --git a/contrib/waldo/models.py b/contrib/waldo/models.py index 183fe49..83724f4 100644 --- a/contrib/waldo/models.py +++ b/contrib/waldo/models.py @@ -257,7 +257,7 @@ class LoginMultiView(MultiView): } self.send_confirmation_email('Confirm account creation at %s' % current_site.name, user.email, self.register_confirmation_email, context) messages.add_message(request, messages.SUCCESS, 'An email has been sent to %s with details on activating your account.' % user.email, fail_silently=True) - return HttpResponseRedirect('') + return HttpResponseRedirect(node.get_absolute_url()) else: form = RegistrationForm()