Added recaptcha support to waldo registration form.
authorStephen Burrows <stephen.r.burrows@gmail.com>
Mon, 13 Sep 2010 17:53:25 +0000 (13:53 -0400)
committerStephen Burrows <stephen.r.burrows@gmail.com>
Thu, 23 Sep 2010 16:31:54 +0000 (12:31 -0400)
contrib/waldo/forms.py
contrib/waldo/models.py

index 4465a99..18c22a4 100644 (file)
@@ -1,5 +1,6 @@
 from datetime import date
 from django import forms
 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
 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)
 
 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']
        
        def clean_username(self):
                username = self.cleaned_data['username']
index 183fe49..83724f4 100644 (file)
@@ -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)
                                }
                                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()
                
                else:
                        form = RegistrationForm()