summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2014-04-25 08:20:25 -0400
committerTim Graham <timograham@gmail.com>2014-04-25 08:20:25 -0400
commit9e7f86b890a71bcc86ec7bcd9ee0c05801b5e807 (patch)
tree6fe0f25250de30cf69574c02bd65a58d24dd3799
parente368912902add8accf08d290ea77df49bd488744 (diff)
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.
-rw-r--r--django/contrib/auth/admin.py2
-rw-r--r--django/contrib/auth/tests/test_views.py12
-rw-r--r--docs/releases/1.6.4.txt6
3 files changed, 18 insertions, 2 deletions
diff --git a/django/contrib/auth/admin.py b/django/contrib/auth/admin.py
index 2eab7efec8..9b75dc59e7 100644
--- a/django/contrib/auth/admin.py
+++ b/django/contrib/auth/admin.py
@@ -129,7 +129,7 @@ class UserAdmin(admin.ModelAdmin):
if form.is_valid():
form.save()
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.')
messages.success(request, msg)
update_session_auth_hash(request, form.user)
diff --git a/django/contrib/auth/tests/test_views.py b/django/contrib/auth/tests/test_views.py
index 6f79516ff4..1f87c7ab79 100644
--- a/django/contrib/auth/tests/test_views.py
+++ b/django/contrib/auth/tests/test_views.py
@@ -866,3 +866,15 @@ class ChangelistTests(AuthViewsTestCase):
self.assertEqual(row.change_message, 'Changed password.')
self.logout()
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.')
diff --git a/docs/releases/1.6.4.txt b/docs/releases/1.6.4.txt
index fd36b21271..58fb42cb43 100644
--- a/docs/releases/1.6.4.txt
+++ b/docs/releases/1.6.4.txt
@@ -15,4 +15,8 @@ Bugfixes
* Restored the ability to :meth:`~django.core.urlresolvers.reverse` views
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>`_).