Code

Ticket #10889: 10889.diff

File 10889.diff, 2.0 KB (added by jdunck, 5 years ago)
Line 
1diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
2index c87d903..f69587b 100644
3--- a/django/contrib/admin/options.py
4+++ b/django/contrib/admin/options.py
5@@ -1010,9 +1010,9 @@ class ModelAdmin(BaseModelAdmin):
6             if perms_needed:
7                 raise PermissionDenied
8             obj_display = force_unicode(obj)
9+            self.log_deletion(request, obj, obj_display)
10             obj.delete()
11 
12-            self.log_deletion(request, obj, obj_display)
13             self.message_user(request, _('The %(name)s "%(obj)s" was deleted successfully.') % {'name': force_unicode(opts.verbose_name), 'obj': force_unicode(obj_display)})
14 
15             if not self.has_change_permission(request, None):
16diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py
17index 3d75967..5e1b35e 100644
18--- a/tests/regressiontests/admin_views/tests.py
19+++ b/tests/regressiontests/admin_views/tests.py
20@@ -6,7 +6,7 @@ from django.core.files import temp as tempfile
21 from django.test import TestCase
22 from django.contrib.auth.models import User, Permission
23 from django.contrib.contenttypes.models import ContentType
24-from django.contrib.admin.models import LogEntry
25+from django.contrib.admin.models import LogEntry, DELETION
26 from django.contrib.admin.sites import LOGIN_FORM_KEY
27 from django.contrib.admin.util import quote
28 from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME
29@@ -544,6 +544,9 @@ class AdminViewPermissionsTest(TestCase):
30         post = self.client.post('/test_admin/admin/admin_views/article/1/delete/', delete_dict)
31         self.assertRedirects(post, '/test_admin/admin/')
32         self.failUnlessEqual(Article.objects.all().count(), 2)
33+        article_ct = ContentType.objects.get_for_model(Article)
34+        logged = LogEntry.objects.get(content_type=article_ct, action_flag=DELETION)
35+        self.failUnlessEqual(logged.object_id, u'1')
36         self.client.get('/test_admin/admin/logout/')
37 
38 class AdminViewStringPrimaryKeyTest(TestCase):