def clean_email(self): email = self.cleaned_data["email"] if user_exists(email): user = get_user(email) if not user.groups.filter(name=SEED_GROUP).exists(): raise forms.ValidationError("A user with that email already exists.") return email
def save(self, commit=True): email = self.cleaned_data["email"] if user_exists(email): # A 'User Seed' existing for this email address. user = get_user(email) user.set_password(self.cleaned_data["password1"]) seed_group = Group.objects.get(name=SEED_GROUP) user.groups.remove(seed_group) else: user = super(NewUserForm, self).save(commit=False) user.first_name = self.cleaned_data["first_name"] user.last_name = self.cleaned_data["last_name"] if commit: user.save() mailingLists = [] if self.cleaned_data["subscribe_announce"]: mailingLists.append("Announcements_General") mailingLists.append("Signed_Up_on_Sefaria") if self.cleaned_data["subscribe_educator"]: mailingLists.append("Announcements_Edu") if mailingLists: try: subscribe_to_list(mailingLists, user.email, first_name=user.first_name, last_name=user.last_name) except: pass return user
def clean_email(self): email = self.cleaned_data["email"] if user_exists(email): user = get_user(email) if not user.groups.filter(name=SEED_GROUP).exists(): raise forms.ValidationError(_("A user with that email already exists.")) return email
def save(self, commit=True): email = self.cleaned_data["email"] if user_exists(email): # A 'User Seed' existing for this email address. user = get_user(email) user.set_password(self.cleaned_data["password1"]) seed_group = Group.objects.get(name=SEED_GROUP) user.groups.remove(seed_group) else: user = super(SefariaNewUserForm, self).save(commit=False) user.first_name = self.cleaned_data["first_name"] user.last_name = self.cleaned_data["last_name"] if commit: user.save() mailingLists = [] language = get_language() list_name = "Announcements_General_Hebrew" if language == "he" else "Announcements_General" mailingLists.append(list_name) if self.cleaned_data["subscribe_educator"]: list_name = "Announcements_Edu_Hebrew" if language == "he" else "Announcements_Edu" mailingLists.append(list_name) if mailingLists: mailingLists.append("Signed_Up_on_Sefaria") try: subscribe_to_list(mailingLists, user.email, first_name=user.first_name, last_name=user.last_name) except: pass return user
def clean_email(self): """ Check the supplied email address against a list of known free webmail domains. """ bad_domains = [ 'aim.com', 'aol.com', 'email.com', 'gmail.com', 'googlemail.com', 'hotmail.com', 'hushmail.com', 'msn.com', 'mail.ru', 'mailinator.com', 'live.com', 'yahoo.com' ] email_domain = self.cleaned_data['email'].split('@')[1] if email_domain in bad_domains: raise forms.ValidationError( ("Please sign up with your company email address.")) email = self.cleaned_data["email"] from emailusernames.utils import user_exists if user_exists(email): raise forms.ValidationError( ("A user with that email already exists.")) return self.cleaned_data['email']
def errors(self): if len(self._errors): return self._errors[0] if user_exists(self.email): u = get_user(self.email) if u.id != self.user.id: self._errors.append(_("A user with that email already exists")) email_val = EmailValidator() try: email_val(self.email) except ValidationError as e: self._errors.append(_("The email address is not valid.")) return self._errors[0] if len(self._errors) else None
def save(self, commit=True): email = self.cleaned_data["email"] if user_exists(email): # A 'User Seed' existing for this email address. user = get_user(email) user.set_password(self.cleaned_data["password1"]) seed_group = Group.objects.get(name=SEED_GROUP) user.groups.remove(seed_group) else: user = super(NewUserForm, self).save(commit=False) user.first_name = self.cleaned_data["first_name"] user.last_name = self.cleaned_data["last_name"] if commit: user.save() if self.cleaned_data["subscribe_announce"]: try: subscribe_to_announce(user.email, first_name=user.first_name, last_name=user.last_name) except: pass return user
def clean_email(self): """ Check the supplied email address against a list of known free webmail domains. """ bad_domains = ['aim.com', 'aol.com', 'email.com', 'gmail.com', 'googlemail.com', 'hotmail.com', 'hushmail.com', 'msn.com', 'mail.ru', 'mailinator.com', 'live.com', 'yahoo.com'] email_domain = self.cleaned_data['email'].split('@')[1] if email_domain in bad_domains: raise forms.ValidationError(("Please sign up with your company email address.")) email = self.cleaned_data["email"] from emailusernames.utils import user_exists if user_exists(email): raise forms.ValidationError(("A user with that email already exists.")) return self.cleaned_data['email']
def save(self, commit=True): email = self.cleaned_data["email"] if user_exists(email): # A 'User Seed' existing for this email address. user = get_user(email) user.set_password(self.cleaned_data["password1"]) seed_group = Group.objects.get(name=SEED_GROUP) user.groups.remove(seed_group) else: user = super(NewUserForm, self).save(commit=False) user.first_name = self.cleaned_data["first_name"] user.last_name = self.cleaned_data["last_name"] if commit: user.save() """if self.cleaned_data["subscribe_announce"]: try: subscribe_to_announce(user.email, first_name=user.first_name, last_name=user.last_name) except: pass """ return user
def clean_email(self): email = self.cleaned_data["email"] if user_exists(email): raise forms.ValidationError(_("A user with that email already exists.")) return email
def clean_email(self): email = self.cleaned_data["email"] if user_exists(email): raise forms.ValidationError( _("A user with that email already exists.")) return email
def clean_email(self): email = self.cleaned_data["email"] if user_exists(email): raise forms.ValidationError(self.error_messages['duplicate_username']) return email
def clean_email(self): email = self.cleaned_data["email"] if user_exists(email): raise forms.ValidationError( self.error_messages['duplicate_username']) return email