shibboleth signup form throughs validation error in case of an inactive account with...
authorSofia Papagiannaki <papagian@gmail.com>
Fri, 27 Apr 2012 08:55:52 +0000 (11:55 +0300)
committerSofia Papagiannaki <papagian@gmail.com>
Fri, 27 Apr 2012 08:55:52 +0000 (11:55 +0300)
snf-astakos-app/astakos/im/forms.py
snf-astakos-app/astakos/im/models.py

index 958c98d..f06ffb4 100644 (file)
@@ -254,6 +254,9 @@ class ShibbolethUserCreationForm(ThirdPartyUserCreationForm):
         for user in AstakosUser.objects.filter(email = email):
             if user.provider == 'shibboleth':
                 raise forms.ValidationError(_("This email is already associated with another shibboleth account."))
+            elif not user.is_active:
+                raise forms.ValidationError(_("This email is already associated with an inactive account. \
+                                              You need to wait to be activated before being able to switch to a shibboleth account."))
         super(ShibbolethUserCreationForm, self).clean_email()
         return email
 
index af00f51..4265ed7 100644 (file)
@@ -137,7 +137,7 @@ class AstakosUser(User):
             if not self.provider:
                 self.provider = 'local'
         report_user_event(self)
-        self.full_clean()
+        self.validate_unique_email_isactive()
         super(AstakosUser, self).save(**kwargs)
         
         # set group if does not exist
@@ -170,12 +170,10 @@ class AstakosUser(User):
             return True
         return False
     
-    def validate_unique(self, exclude=None):
+    def validate_unique_email_isactive(self):
         """
         Implements a unique_together constraint for email and is_active fields.
         """
-        super(AstakosUser, self).validate_unique(exclude)
-        
         q = AstakosUser.objects.exclude(username = self.username)
         q = q.filter(email = self.email)
         q = q.filter(is_active = self.is_active)