Ticket #18550: unquote_history_view.patch

File unquote_history_view.patch, 1.9 KB (added by josh.oosterman@…, 12 years ago)
  • django/contrib/admin/options.py

    diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
    index 3b899e5..665e3f7 100644
    a b class ModelAdmin(BaseModelAdmin):  
    13211321        opts = model._meta
    13221322        app_label = opts.app_label
    13231323        action_list = LogEntry.objects.filter(
    1324             object_id = object_id,
     1324            object_id = unquote(object_id),
    13251325            content_type__id__exact = ContentType.objects.get_for_model(model).id
    13261326        ).select_related().order_by('action_time')
    13271327        # If no history was found, see whether this object even exists.
  • tests/regressiontests/admin_views/tests.py

    diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py
    index f074d77..be4b32d 100644
    a b class AdminViewStringPrimaryKeyTest(TestCase):  
    13441344    def setUp(self):
    13451345        self.client.login(username='super', password='secret')
    13461346        content_type_pk = ContentType.objects.get_for_model(ModelWithStringPrimaryKey).pk
    1347         LogEntry.objects.log_action(100, content_type_pk, self.pk, self.pk, 2, change_message='')
     1347        LogEntry.objects.log_action(100, content_type_pk, self.pk, self.pk, 2, change_message='Change message')
    13481348
    13491349    def tearDown(self):
    13501350        self.client.logout()
    class AdminViewStringPrimaryKeyTest(TestCase):  
    13531353        "Retrieving the history for the object using urlencoded form of primary key should work"
    13541354        response = self.client.get('/test_admin/admin/admin_views/modelwithstringprimarykey/%s/history/' % quote(self.pk))
    13551355        self.assertContains(response, escape(self.pk))
     1356        self.assertNotContains(response, 'This object doesn’t have a change history.')
     1357        self.assertContains(response, 'Change message')
    13561358        self.assertEqual(response.status_code, 200)
    13571359
    13581360    def test_get_change_view(self):
Back to Top