added clean email
authornishanth
Sat, 29 May 2010 15:49:48 +0530
changeset 21 3d7a52d9ed2e
parent 20 9db4ee082d4e
child 22 1df4b0e0d45c
added clean email
sdi/forms.py
--- a/sdi/forms.py	Sat May 29 15:46:00 2010 +0530
+++ b/sdi/forms.py	Sat May 29 15:49:48 2010 +0530
@@ -10,6 +10,17 @@
     class Meta:
         model = Registrant
 
+    def clean_email(self):
+        """ See if the user has already registered using the email.
+        """
+
+        email = self.cleaned_data['email'].strip()
+        try:
+            Registrant.objects.get(email__iexact=email)
+            raise forms.ValidationError("This email is already registered. Did you register earlier??")
+        except Registrant.DoesNotExist:
+            return email
+
     def clean_topics_interested(self):
         """ Join the choices using PIPE character and store them.
         """