Fixed #22515 -- Fixed the object_id of the LogEntry that's created after a user password change in the admin.

Thanks ross at servercode.co.uk for the report.
This commit is contained in:
Tim Graham 2014-04-25 08:20:25 -04:00
parent e368912902
commit 9e7f86b890
3 changed files with 18 additions and 2 deletions

View File

@ -129,7 +129,7 @@ class UserAdmin(admin.ModelAdmin):
if form.is_valid(): if form.is_valid():
form.save() form.save()
change_message = self.construct_change_message(request, form, None) change_message = self.construct_change_message(request, form, None)
self.log_change(request, request.user, change_message) self.log_change(request, user, change_message)
msg = ugettext('Password changed successfully.') msg = ugettext('Password changed successfully.')
messages.success(request, msg) messages.success(request, msg)
update_session_auth_hash(request, form.user) update_session_auth_hash(request, form.user)

View File

@ -866,3 +866,15 @@ class ChangelistTests(AuthViewsTestCase):
self.assertEqual(row.change_message, 'Changed password.') self.assertEqual(row.change_message, 'Changed password.')
self.logout() self.logout()
self.login(password='password1') self.login(password='password1')
def test_user_change_different_user_password(self):
u = User.objects.get(email='staffmember@example.com')
response = self.client.post('/admin/auth/user/%s/password/' % u.pk, {
'password1': 'password1',
'password2': 'password1',
})
self.assertRedirects(response, '/admin/auth/user/%s/' % u.pk)
row = LogEntry.objects.latest('id')
self.assertEqual(row.user_id, self.admin.pk)
self.assertEqual(row.object_id, str(u.pk))
self.assertEqual(row.change_message, 'Changed password.')

View File

@ -15,4 +15,8 @@ Bugfixes
* Restored the ability to :meth:`~django.core.urlresolvers.reverse` views * Restored the ability to :meth:`~django.core.urlresolvers.reverse` views
created using :func:`functools.partial()` created using :func:`functools.partial()`
(`#22486 <http://code.djangoproject.com/ticket/22486>`_) (`#22486 <http://code.djangoproject.com/ticket/22486>`_).
* Fixed the ``object_id`` of the ``LogEntry`` that's created after a user
password change in the admin
(`#22515 <http://code.djangoproject.com/ticket/22515>`_).