From f819bef3dc935851f71e4ad84592eee8664a48f3 Mon Sep 17 00:00:00 2001 From: Javier Mansilla Date: Tue, 26 Feb 2013 00:27:52 -0300 Subject: Fixed #19773 - Added admin/popup_response.html template. Thanks jimmylam@ for the suggestion. --- tests/admin_views/models.py | 2 +- tests/admin_views/tests.py | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'tests/admin_views') diff --git a/tests/admin_views/models.py b/tests/admin_views/models.py index 5cc6f6251a..5ec4fbb544 100644 --- a/tests/admin_views/models.py +++ b/tests/admin_views/models.py @@ -137,7 +137,7 @@ class Thing(models.Model): class Actor(models.Model): name = models.CharField(max_length=50) age = models.IntegerField() - title = models.CharField(max_length=50, null=True) + title = models.CharField(max_length=50, null=True, blank=True) def __str__(self): return self.name diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index 528c728069..064979801e 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -2554,6 +2554,17 @@ action) '/test_admin/admin/admin_views/subscriber/?%s' % IS_POPUP_VAR) self.assertEqual(response.context["action_form"], None) + def test_popup_template_response(self): + """ + Success on popups shall be rendered from template in order to allow + easy customization. + """ + response = self.client.post( + '/test_admin/admin/admin_views/actor/add/?%s=1' % IS_POPUP_VAR, + {'name': 'Troy McClure', 'age': '55', IS_POPUP_VAR: '1'}) + self.assertEqual(response.status_code, 200) + self.assertEqual(response.template_name, 'admin/popup_response.html') + @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) class TestCustomChangeList(TestCase): @@ -4275,7 +4286,7 @@ class AdminKeepChangeListFiltersTests(TestCase): # Get the `add_view`. response = self.client.get(self.get_add_url()) self.assertEqual(response.status_code, 200) - + # Check the form action. form_action = """
""" % self.get_preserved_filters_querystring() self.assertContains(response, form_action, count=1) -- cgit v1.3 From 534ced5aadf964eca4cf29a689dc70185f582772 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Thu, 27 Jun 2013 19:39:20 -0400 Subject: Fixed #20664 -- Fixed a bug with raw_id_fields on Python 3. Thanks jefftriplett for the report. --- django/contrib/admin/templatetags/admin_list.py | 6 +++--- tests/admin_views/tests.py | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'tests/admin_views') diff --git a/django/contrib/admin/templatetags/admin_list.py b/django/contrib/admin/templatetags/admin_list.py index e81b13cda4..8596dfb825 100644 --- a/django/contrib/admin/templatetags/admin_list.py +++ b/django/contrib/admin/templatetags/admin_list.py @@ -11,7 +11,7 @@ from django.contrib.admin.templatetags.admin_static import static from django.core.exceptions import ObjectDoesNotExist from django.db import models from django.utils import formats -from django.utils.html import format_html +from django.utils.html import escapejs, format_html from django.utils.safestring import mark_safe from django.utils.text import capfirst from django.utils.translation import ugettext as _ @@ -226,12 +226,12 @@ def items_for_result(cl, result, form): else: attr = pk value = result.serializable_value(attr) - result_id = repr(force_text(value))[1:] + result_id = escapejs(value) yield format_html('<{0}{1}>{4}', table_tag, row_class, url, - format_html(' onclick="opener.dismissRelatedLookupPopup(window, {0}); return false;"', result_id) + format_html(' onclick="opener.dismissRelatedLookupPopup(window, '{0}'); return false;"', result_id) if cl.is_popup else '', result_repr, table_tag) diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index 064979801e..a695d50ea2 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -583,6 +583,14 @@ class AdminViewBasicTest(TestCase): response = self.client.get("/test_admin/admin/admin_views/inquisition/?leader__name=Palin&leader__age=27") self.assertEqual(response.status_code, 200) + def test_popup_dismiss_related(self): + """ + Regression test for ticket 20664 - ensure the pk is properly quoted. + """ + actor = Actor.objects.create(name="Palin", age=27) + response = self.client.get("/test_admin/admin/admin_views/actor/?%s" % IS_POPUP_VAR) + self.assertContains(response, "opener.dismissRelatedLookupPopup(window, '%s')" % actor.pk) + def test_hide_change_password(self): """ Tests if the "change password" link in the admin is hidden if the User -- cgit v1.3 From 7c0b72a826a3637b30a57553ac83f6b913c33134 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Thu, 27 Jun 2013 20:13:42 -0400 Subject: Prevented running some admin_view tests twice. --- tests/admin_views/tests.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tests/admin_views') diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index a695d50ea2..235fe0cb54 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -57,7 +57,7 @@ for a staff account. Note that both fields may be case-sensitive." @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) -class AdminViewBasicTest(TestCase): +class AdminViewBasicTestCase(TestCase): fixtures = ['admin-views-users.xml', 'admin-views-colors.xml', 'admin-views-fabrics.xml', 'admin-views-books.xml'] @@ -92,6 +92,7 @@ class AdminViewBasicTest(TestCase): failing_msg ) +class AdminViewBasicTest(AdminViewBasicTestCase): def testTrailingSlashRequired(self): """ If you leave off the trailing slash, app should redirect and add it. @@ -761,7 +762,7 @@ class SaveAsTests(TestCase): self.assertEqual(response.context['form_url'], '/test_admin/admin/admin_views/person/add/') -class CustomModelAdminTest(AdminViewBasicTest): +class CustomModelAdminTest(AdminViewBasicTestCase): urls = "admin_views.urls" urlbit = "admin2" -- cgit v1.3