def save(self, domain=None, email_template=None, email_subject=None, email_sender=None, commit=True): domain = domain or htk_setting('HTK_DEFAULT_EMAIL_SENDING_DOMAIN') user = super(NameEmailUserRegistrationForm, self).save(commit=False) email = self.email # temporarily assign a unique username so that we can create the record and the user can log in if htk_setting('HTK_ACCOUNTS_REGISTER_SET_PRETTY_USERNAME_FROM_EMAIL', False): user.username = email_to_username_pretty_unique(email) else: user.username = email_to_username_hash(email) #password1 = self.cleaned_data.get('password1') #user.set_password(password1) if commit: user.save() # associate user and email from htk.apps.accounts.utils import associate_user_email user_email = associate_user_email(user, email, domain=domain, email_template=email_template, email_subject=email_subject, email_sender=email_sender) # mark has_username_set user_profile = user.profile user_profile.has_username_set = True user_profile.save() # send welcome email was_activated = user.is_active if was_activated: user_profile.send_welcome_email() return user
def _process_registration(self, domain, email_template, email_subject, email_sender, commit): domain = domain or htk_setting('HTK_DEFAULT_EMAIL_SENDING_DOMAIN') user = super(UserRegistrationForm, self).save(commit=False) # temporarily assign a unique username so that we can create the record and the user can log in if htk_setting( 'HTK_ACCOUNTS_REGISTER_SET_PRETTY_USERNAME_FROM_EMAIL', False): user.username = email_to_username_pretty_unique(email) else: user.username = email_to_username_hash(email) # we'll store the primary email in the User object user.email = email if not htk_setting('HTK_ACCOUNT_ACTIVATE_UPON_REGISTRATION', False): # require user to confirm email account before activating it user.is_active = False if commit: user.save() from htk.apps.accounts.utils import associate_user_email user_email = associate_user_email( user, email, domain=domain, email_template=email_template, email_subject=email_subject, email_sender=email_sender) return user
def save(self, domain=DEFAULT_EMAIL_SENDING_DOMAIN, commit=True): user = super(UserRegistrationForm, self).save(commit=False) email = self.email # temporarily assign a unique username so that we can create the record and the user can log in user.username = email_to_username_hash(email) # we'll store the primary email in the User object user.email = email user.primary_email = email # require user to confirm email account before activating it user.is_active = False if commit: user.save() user_email = associate_user_email(user, email, domain) return user
def save(self, domain=None, commit=True): domain = domain or htk_setting('HTK_DEFAULT_EMAIL_SENDING_DOMAIN') user = super(UserRegistrationForm, self).save(commit=False) email = self.email # temporarily assign a unique username so that we can create the record and the user can log in user.username = email_to_username_hash(email) # we'll store the primary email in the User object user.email = email if not htk_setting('HTK_ACCOUNT_ACTIVATE_UPON_REGISTRATION', False): # require user to confirm email account before activating it user.is_active = False if commit: user.save() from htk.apps.accounts.utils import associate_user_email user_email = associate_user_email(user, email, domain) return user
def _process_registration(self, domain, email_template, email_subject, email_sender, commit): domain = domain or htk_setting('HTK_DEFAULT_EMAIL_SENDING_DOMAIN') user = super(UserRegistrationForm, self).save(commit=False) # temporarily assign a unique username so that we can create the record and the user can log in if htk_setting('HTK_ACCOUNTS_REGISTER_SET_PRETTY_USERNAME_FROM_EMAIL', False): user.username = email_to_username_pretty_unique(email) else: user.username = email_to_username_hash(email) # we'll store the primary email in the User object user.email = email if not htk_setting('HTK_ACCOUNT_ACTIVATE_UPON_REGISTRATION', False): # require user to confirm email account before activating it user.is_active = False if commit: user.save() from htk.apps.accounts.utils import associate_user_email user_email = associate_user_email(user, email, domain=domain, email_template=email_template, email_subject=email_subject, email_sender=email_sender) return user