def test_mail_page_user_change(self): user = User.objects.create_superuser("username", "*****@*****.**", "username") user = create_page_user(user, user, grant_all=True) mail_page_user_change(user) self.assertEqual(len(mail.outbox), 1)
def save(self, commit=True): """Create user, assign him to staff users, and create permissions for him if required. Also assigns creator to user. """ page_user = super(PageUserForm, self).save(commit=False) created = not page_user.created_by_id # assign creator to user if created: get_current_user() page_user.created_by = get_current_user() if commit: page_user.save() save_permissions(self.cleaned_data, page_user) if self.cleaned_data['notify_user']: mail_page_user_change(page_user, created, self.cleaned_data['password1']) return page_user
def save(self, commit=True): """Create user, assign him to staff users, and create permissions for him if required. Also assigns creator to user. """ Super = self._password_change and PageUserForm or UserCreationForm user = super(Super, self).save(commit=False) user.is_staff = True created = not bool(user.pk) # assign creator to user if created: get_current_user() user.created_by = get_current_user() if commit: user.save() save_permissions(self.cleaned_data, user) if self.cleaned_data['notify_user']: mail_page_user_change(user, created, self.cleaned_data['password1']) return user
def save(self, commit=True): """Create user, assign him to staff users, and create permissions for him if required. Also assigns creator to user. """ Super = self._password_change and PageUserForm or UserCreationForm user = super(Super, self).save(commit=False) user.is_staff = True created = not bool(user.pk) # assign creator to user if created: get_current_user() user.created_by = get_current_user() if commit: user.save() save_permissions(self.cleaned_data, user) if self.cleaned_data['notify_user']: mail_page_user_change(user, created, self.cleaned_data['password1']) return user
def test_mail_page_user_change(self): User = auth.get_user_model() user = User.objects.create_superuser("username", "*****@*****.**", "username") user = create_page_user(user, user, grant_all=True) mail_page_user_change(user) self.assertEqual(len(mail.outbox), 1)
def test_mail_page_user_change(self): user = get_user_model().objects.create_superuser( "username", "*****@*****.**", "username") user = create_page_user(user, user, grant_all=True) mail_page_user_change(user) self.assertEqual(len(mail.outbox), 1)