diff options
| author | David Sanders <dsanders11@ucsbalum.com> | 2021-05-19 11:10:58 -0700 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-05-20 07:04:26 +0200 |
| commit | 2978c63a34b4aa0f170a1e5a0f8f4cb2811fa248 (patch) | |
| tree | fffd7274005dd197999fc23f103e7f98c4434bc0 /tests | |
| parent | 6e155d280dbe4bab171619654d8abc4b7f197e78 (diff) | |
Fixed #32771 -- Used IS_POPUP_VAR constant instead of hard-coded value.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/admin_custom_urls/tests.py | 3 | ||||
| -rw-r--r-- | tests/admin_views/templates/admin/admin_views/article/search_form.html | 2 | ||||
| -rw-r--r-- | tests/admin_views/tests.py | 16 |
3 files changed, 11 insertions, 10 deletions
diff --git a/tests/admin_custom_urls/tests.py b/tests/admin_custom_urls/tests.py index e0c2d4f746..ebd3291f2c 100644 --- a/tests/admin_custom_urls/tests.py +++ b/tests/admin_custom_urls/tests.py @@ -1,4 +1,5 @@ from django.contrib.admin.utils import quote +from django.contrib.admin.views.main import IS_POPUP_VAR from django.contrib.auth.models import User from django.template.response import TemplateResponse from django.test import TestCase, override_settings @@ -58,7 +59,7 @@ class AdminCustomUrlsTest(TestCase): Ensure POST on add_view works. """ post_data = { - '_popup': '1', + IS_POPUP_VAR: '1', "name": 'Action added through a popup', "description": "Description of added action", } diff --git a/tests/admin_views/templates/admin/admin_views/article/search_form.html b/tests/admin_views/templates/admin/admin_views/article/search_form.html index eef986cb30..3388766104 100644 --- a/tests/admin_views/templates/admin/admin_views/article/search_form.html +++ b/tests/admin_views/templates/admin/admin_views/article/search_form.html @@ -6,7 +6,7 @@ <input type="text" size="40" name="{{ search_var }}" value="{{ cl.query }}" id="searchbar" autofocus /> <input type="submit" value="{% translate 'Search' %}" /> {% if show_result_count %} - <span class="small quiet">{% blocktranslate count counter=cl.result_count %}{{ counter }} result{% plural %}{{ counter }} results{% endblocktranslate %} (<a href="?{% if cl.is_popup %}_popup=1{% endif %}">{% if cl.show_full_result_count %}{% blocktranslate with full_result_count=cl.full_result_count %}{{ full_result_count }} total{% endblocktranslate %}{% else %}{% translate "Show all" %}{% endif %}</a>)</span> + <span class="small quiet">{% blocktranslate count counter=cl.result_count %}{{ counter }} result{% plural %}{{ counter }} results{% endblocktranslate %} (<a href="?{% if cl.is_popup %}{{ is_popup_var }}=1{% endif %}">{% if cl.show_full_result_count %}{% blocktranslate with full_result_count=cl.full_result_count %}{{ full_result_count }} total{% endblocktranslate %}{% else %}{% translate "Show all" %}{% endif %}</a>)</span> {% endif %} {% for pair in cl.params.items %} {% if pair.0 != search_var %}<input type="hidden" name="{{ pair.0 }}" value="{{ pair.1 }}"/>{% endif %} diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index 69fd43ba8f..880ba0b85f 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -293,7 +293,7 @@ class AdminViewBasicTest(AdminViewBasicTestCase): Ensure http response from a popup is properly escaped. """ post_data = { - '_popup': '1', + IS_POPUP_VAR: '1', 'title': 'title with a new\nline', 'content': 'some content', 'date_0': '2010-09-10', @@ -5391,17 +5391,17 @@ class UserAdminTest(TestCase): response = self.client.get(reverse('admin:admin_views_album_add')) self.assertContains(response, reverse('admin:auth_user_add')) self.assertContains(response, 'class="related-widget-wrapper-link add-related" id="add_id_owner"') - response = self.client.get(reverse('admin:auth_user_add') + '?_popup=1') + response = self.client.get(reverse('admin:auth_user_add') + '?%s=1' % IS_POPUP_VAR) self.assertNotContains(response, 'name="_continue"') self.assertNotContains(response, 'name="_addanother"') data = { 'username': 'newuser', 'password1': 'newpassword', 'password2': 'newpassword', - '_popup': '1', + IS_POPUP_VAR: '1', '_save': '1', } - response = self.client.post(reverse('admin:auth_user_add') + '?_popup=1', data, follow=True) + response = self.client.post(reverse('admin:auth_user_add') + '?%s=1' % IS_POPUP_VAR, data, follow=True) self.assertContains(response, '"obj": "newuser"') def test_user_fk_change_popup(self): @@ -5410,7 +5410,7 @@ class UserAdminTest(TestCase): self.assertContains(response, reverse('admin:auth_user_change', args=('__fk__',))) self.assertContains(response, 'class="related-widget-wrapper-link change-related" id="change_id_owner"') user = User.objects.get(username='changeuser') - url = reverse('admin:auth_user_change', args=(user.pk,)) + '?_popup=1' + url = reverse('admin:auth_user_change', args=(user.pk,)) + '?%s=1' % IS_POPUP_VAR response = self.client.get(url) self.assertNotContains(response, 'name="_continue"') self.assertNotContains(response, 'name="_addanother"') @@ -5422,7 +5422,7 @@ class UserAdminTest(TestCase): 'last_login_1': '13:20:10', 'date_joined_0': '2007-05-30', 'date_joined_1': '13:20:10', - '_popup': '1', + IS_POPUP_VAR: '1', '_save': '1', } response = self.client.post(url, data, follow=True) @@ -5435,12 +5435,12 @@ class UserAdminTest(TestCase): self.assertContains(response, reverse('admin:auth_user_delete', args=('__fk__',))) self.assertContains(response, 'class="related-widget-wrapper-link change-related" id="change_id_owner"') user = User.objects.get(username='changeuser') - url = reverse('admin:auth_user_delete', args=(user.pk,)) + '?_popup=1' + url = reverse('admin:auth_user_delete', args=(user.pk,)) + '?%s=1' % IS_POPUP_VAR response = self.client.get(url) self.assertEqual(response.status_code, 200) data = { 'post': 'yes', - '_popup': '1', + IS_POPUP_VAR: '1', } response = self.client.post(url, data, follow=True) self.assertContains(response, '"action": "delete"') |
