Ticket #20664: 20664.diff

File 20664.diff, 2.0 KB (added by Tim Graham, 11 years ago)
  • django/contrib/admin/templatetags/admin_list.py

    diff --git a/django/contrib/admin/templatetags/admin_list.py b/django/contrib/admin/templatetags/admin_list.py
    index e81b13c..842ae12 100644
    a b def items_for_result(cl, result, form):  
    226226            else:
    227227                attr = pk
    228228            value = result.serializable_value(attr)
    229             result_id = repr(force_text(value))[1:]
     229            result_id = force_text(value)
    230230            yield format_html('<{0}{1}><a href="{2}"{3}>{4}</a></{5}>',
    231231                              table_tag,
    232232                              row_class,
    233233                              url,
    234                               format_html(' onclick="opener.dismissRelatedLookupPopup(window, {0}); return false;"', result_id)
     234                              format_html(' onclick="opener.dismissRelatedLookupPopup(window, &#39;{0}&#39;); return false;"', result_id)
    235235                                if cl.is_popup else '',
    236236                              result_repr,
    237237                              table_tag)
  • tests/admin_views/tests.py

    diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py
    index 0649798..2e87b1f 100644
    a b class AdminViewBasicTest(TestCase):  
    583583        response = self.client.get("/test_admin/admin/admin_views/inquisition/?leader__name=Palin&leader__age=27")
    584584        self.assertEqual(response.status_code, 200)
    585585
     586    def test_popup_dismiss_related(self):
     587        """
     588        Regressions test for ticket 20664 - ensure the pk is properly quoted.
     589        """
     590        actor = Actor.objects.create(name="Palin", age=27)
     591        response = self.client.get("/test_admin/admin/admin_views/actor/?%s" % IS_POPUP_VAR)
     592        self.assertContains(response, "opener.dismissRelatedLookupPopup(window, &#39;%s&#39;)" % actor.pk)
     593
    586594    def test_hide_change_password(self):
    587595        """
    588596        Tests if the "change password" link in the admin is hidden if the User
Back to Top