def save(self, profile_callback=None, event=None): # #new_user = RegistrationProfile.objects.create_inactive_user(username=self.cleaned_data['username'], # password=self.cleaned_data['password1'], # create inactive user email=self.cleaned_data['email']) # 不再使用用户名登录,只用email登录,注册时用户没有输入username用email代替 new_user = User.objects.create_user( self.cleaned_data['email'], # self.cleaned_data['username'], self.cleaned_data['email'], self.cleaned_data['password1']) # new_user.first_name = self.cleaned_data['first_name'] # new_user.last_name = self.cleaned_data['last_name'] new_user.is_active = False new_user.save() # create registration profile registration_profile = RegistrationProfile.objects.create_profile( new_user) send_registration_activation_email(new_user, registration_profile, event=event) new_profile = Profile( user=new_user, # company=self.cleaned_data['company'], # phone=self.cleaned_data['phone'], # address=self.cleaned_data['address'], # city=self.cleaned_data['city'], # state=self.cleaned_data['state'], # country=self.cleaned_data['country'], # zipcode=self.cleaned_data['zipcode'], ) user_hide_default = get_setting('module', 'users', 'usershidedefault') if user_hide_default: new_profile.hide_in_search = 1 new_profile.hide_address = 1 new_profile.hide_email = 1 new_profile.hide_phone = 1 new_profile.creator = new_user new_profile.creator_username = new_user.username new_profile.owner = new_user new_profile.owner_username = new_user.username new_profile.save() sf_id = create_salesforce_contact(new_profile) return new_user
def save(self, profile_callback=None, event=None): # #new_user = RegistrationProfile.objects.create_inactive_user(username=self.cleaned_data['username'], # password=self.cleaned_data['password1'], # create inactive user email=self.cleaned_data['email']) new_user = User.objects.create_user(self.cleaned_data['username'], self.cleaned_data['email'], self.cleaned_data['password1']) new_user.first_name = self.cleaned_data['first_name'] new_user.last_name = self.cleaned_data['last_name'] new_user.is_active = False new_user.save() # create registration profile registration_profile = RegistrationProfile.objects.create_profile(new_user) send_registration_activation_email(new_user, registration_profile, event=event) new_profile = Profile(user=new_user, company=self.cleaned_data['company'], phone=self.cleaned_data['phone'], address=self.cleaned_data['address'], city=self.cleaned_data['city'], state=self.cleaned_data['state'], country=self.cleaned_data['country'], zipcode=self.cleaned_data['zipcode'], ) user_hide_default = get_setting('module', 'users', 'usershidedefault') if user_hide_default: new_profile.hide_in_search = 1 new_profile.hide_address = 1 new_profile.hide_email = 1 new_profile.hide_phone = 1 new_profile.creator = new_user new_profile.creator_username = new_user.username new_profile.owner = new_user new_profile.owner_username = new_user.username new_profile.save() sf_id = create_salesforce_contact(new_profile) return new_user