From 9d28568cb41f86a6d5381004799941d7e6654596 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Tue, 5 May 2009 11:52:03 +0000 Subject: [PATCH] Fixed #10275 -- Corrected the edge case of rendering a LogEntry with a contenttype of None. Thanks to Jarek Zgoda for the report, and Peter Bengtsson for the patch git-svn-id: http://code.djangoproject.com/svn/django/trunk@10675 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- .../contrib/admin/templates/admin/index.html | 14 +++++++++- tests/regressiontests/admin_views/tests.py | 28 ++++++++++++++++--- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/django/contrib/admin/templates/admin/index.html b/django/contrib/admin/templates/admin/index.html index 808ed334f4..772474bea5 100644 --- a/django/contrib/admin/templates/admin/index.html +++ b/django/contrib/admin/templates/admin/index.html @@ -59,7 +59,19 @@ {% else %} {% endif %} diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py index 3d75967444..960923bbef 100644 --- a/tests/regressiontests/admin_views/tests.py +++ b/tests/regressiontests/admin_views/tests.py @@ -579,6 +579,26 @@ class AdminViewStringPrimaryKeyTest(TestCase): should_contain = """%s""" % (quote(self.pk), escape(self.pk)) self.assertContains(response, should_contain) + def test_recentactions_without_content_type(self): + "If a LogEntry is missing content_type it will not display it in span tag under the hyperlink." + response = self.client.get('/test_admin/admin/') + should_contain = """%s""" % (quote(self.pk), escape(self.pk)) + self.assertContains(response, should_contain) + should_contain = "Model with string primary key" # capitalized in Recent Actions + self.assertContains(response, should_contain) + logentry = LogEntry.objects.get(content_type__name__iexact=should_contain) + # http://code.djangoproject.com/ticket/10275 + # if the log entry doesn't have a content type it should still be + # possible to view the Recent Actions part + logentry.content_type = None + logentry.save() + + counted_presence_before = response.content.count(should_contain) + response = self.client.get('/test_admin/admin/') + counted_presence_after = response.content.count(should_contain) + self.assertEquals(counted_presence_before - 1, + counted_presence_after) + def test_deleteconfirmation_link(self): "The link from the delete confirmation page referring back to the changeform of the object should be quoted" response = self.client.get('/test_admin/admin/admin_views/modelwithstringprimarykey/%s/delete/' % quote(self.pk)) @@ -1003,7 +1023,7 @@ class AdminActionsTest(TestCase): } response = self.client.post('/test_admin/admin/admin_views/externalsubscriber/', action_data) self.failUnlessEqual(response.status_code, 302) - + def test_model_without_action(self): "Tests a ModelAdmin without any action" response = self.client.get('/test_admin/admin/admin_views/oldsubscriber/') @@ -1012,7 +1032,7 @@ class AdminActionsTest(TestCase): '