manager: don't show a message if email is not changed (fixes #21814)
This commit is contained in:
parent
65769ac3e8
commit
d645e3ee27
|
@ -353,7 +353,9 @@ class UserChangeEmailView(BaseEditView):
|
|||
title = _('Change user email')
|
||||
|
||||
def get_success_message(self, cleaned_data):
|
||||
return ugettext('A mail was sent to %s to verify it.') % cleaned_data['new_email']
|
||||
if cleaned_data['new_email'] != self.object.email:
|
||||
return ugettext('A mail was sent to %s to verify it.') % cleaned_data['new_email']
|
||||
return None
|
||||
|
||||
def form_valid(self, form):
|
||||
response = super(UserChangeEmailView, self).form_valid(form)
|
||||
|
|
|
@ -48,6 +48,28 @@ def test_manager_user_change_email(app, superuser_or_admin, simple_user, mailout
|
|||
assert simple_user.email == NEW_EMAIL
|
||||
|
||||
|
||||
def test_manager_user_change_email_no_change(app, superuser_or_admin, simple_user, mailoutbox):
|
||||
ou = get_default_ou()
|
||||
ou.validate_emails = True
|
||||
ou.save()
|
||||
|
||||
NEW_EMAIL = 'john.doe@example.com'
|
||||
|
||||
assert NEW_EMAIL != simple_user.email
|
||||
|
||||
response = login(app, superuser_or_admin,
|
||||
reverse('a2-manager-user-by-uuid-detail',
|
||||
kwargs={'slug': unicode(simple_user.uuid)}))
|
||||
assert 'Change user email' in response.content
|
||||
# cannot click it's a submit button :/
|
||||
response = app.get(reverse('a2-manager-user-by-uuid-change-email',
|
||||
kwargs={'slug': unicode(simple_user.uuid)}))
|
||||
assert response.form['new_email'].value == simple_user.email
|
||||
assert len(mailoutbox) == 0
|
||||
response = response.form.submit().follow()
|
||||
assert 'A mail was sent to john.doe@example.com to verify it.' not in response.content
|
||||
|
||||
|
||||
def test_search_by_attribute(app, simple_user, admin):
|
||||
Attribute.objects.create(name='adresse', searchable=True, kind='string')
|
||||
|
||||
|
|
Loading…
Reference in New Issue