Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #10899 -- Ensured that log messages for deletions in the admin …

…contain useful descriptions. Thanks to Jeremy Dunck for the patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@10686 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit ae7d9bfad2c92ebe30ce8ca0a145eba4504312f1 1 parent b5f0aff
Russell Keith-Magee authored May 07, 2009
2  django/contrib/admin/options.py
@@ -1012,9 +1012,9 @@ def delete_view(self, request, object_id, extra_context=None):
1012 1012
             if perms_needed:
1013 1013
                 raise PermissionDenied
1014 1014
             obj_display = force_unicode(obj)
  1015
+            self.log_deletion(request, obj, obj_display)
1015 1016
             obj.delete()
1016 1017
 
1017  
-            self.log_deletion(request, obj, obj_display)
1018 1018
             self.message_user(request, _('The %(name)s "%(obj)s" was deleted successfully.') % {'name': force_unicode(opts.verbose_name), 'obj': force_unicode(obj_display)})
1019 1019
 
1020 1020
             if not self.has_change_permission(request, None):
5  tests/regressiontests/admin_views/tests.py
@@ -6,7 +6,7 @@
6 6
 from django.test import TestCase
7 7
 from django.contrib.auth.models import User, Permission
8 8
 from django.contrib.contenttypes.models import ContentType
9  
-from django.contrib.admin.models import LogEntry
  9
+from django.contrib.admin.models import LogEntry, DELETION
10 10
 from django.contrib.admin.sites import LOGIN_FORM_KEY
11 11
 from django.contrib.admin.util import quote
12 12
 from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME
@@ -544,6 +544,9 @@ def testDeleteView(self):
544 544
         post = self.client.post('/test_admin/admin/admin_views/article/1/delete/', delete_dict)
545 545
         self.assertRedirects(post, '/test_admin/admin/')
546 546
         self.failUnlessEqual(Article.objects.all().count(), 2)
  547
+        article_ct = ContentType.objects.get_for_model(Article)
  548
+        logged = LogEntry.objects.get(content_type=article_ct, action_flag=DELETION)
  549
+        self.failUnlessEqual(logged.object_id, u'1')
547 550
         self.client.get('/test_admin/admin/logout/')
548 551
 
549 552
 class AdminViewStringPrimaryKeyTest(TestCase):

0 notes on commit ae7d9bf

Please sign in to comment.
Something went wrong with that request. Please try again.