diff --git a/django/contrib/admin/templates/admin/auth/user/change_password.html b/django/contrib/admin/templates/admin/auth/user/change_password.html index c107161a93e..730e4c5751b 100644 --- a/django/contrib/admin/templates/admin/auth/user/change_password.html +++ b/django/contrib/admin/templates/admin/auth/user/change_password.html @@ -19,7 +19,7 @@ {% csrf_token %}{% block form_top %}{% endblock %}
-{% if is_popup %}{% endif %} +{% if is_popup %}{% endif %} {% if form.errors %}

{% if form.errors.items|length == 1 %}{% translate "Please correct the error below." %}{% else %}{% translate "Please correct the errors below." %}{% endif %} diff --git a/django/contrib/admin/templates/admin/search_form.html b/django/contrib/admin/templates/admin/search_form.html index 3ec37f2ef78..75c629cd621 100644 --- a/django/contrib/admin/templates/admin/search_form.html +++ b/django/contrib/admin/templates/admin/search_form.html @@ -6,7 +6,7 @@ {% if show_result_count %} - {% blocktranslate count counter=cl.result_count %}{{ counter }} result{% plural %}{{ counter }} results{% endblocktranslate %} ({% 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 %}) + {% blocktranslate count counter=cl.result_count %}{{ counter }} result{% plural %}{{ counter }} results{% endblocktranslate %} ({% 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 %}) {% endif %} {% for pair in cl.params.items %} {% if pair.0 != search_var %}{% endif %} diff --git a/django/contrib/admin/templatetags/admin_list.py b/django/contrib/admin/templatetags/admin_list.py index 86eade6fed4..b82440e9f88 100644 --- a/django/contrib/admin/templatetags/admin_list.py +++ b/django/contrib/admin/templatetags/admin_list.py @@ -6,7 +6,7 @@ from django.contrib.admin.utils import ( label_for_field, lookup_field, ) from django.contrib.admin.views.main import ( - ALL_VAR, ORDER_VAR, PAGE_VAR, SEARCH_VAR, + ALL_VAR, IS_POPUP_VAR, ORDER_VAR, PAGE_VAR, SEARCH_VAR, ) from django.core.exceptions import ObjectDoesNotExist from django.db import models @@ -423,7 +423,8 @@ def search_form(cl): return { 'cl': cl, 'show_result_count': cl.result_count != cl.full_result_count, - 'search_var': SEARCH_VAR + 'search_var': SEARCH_VAR, + 'is_popup_var': IS_POPUP_VAR, } diff --git a/django/contrib/auth/admin.py b/django/contrib/auth/admin.py index 6709e634850..a63a4e28a73 100644 --- a/django/contrib/auth/admin.py +++ b/django/contrib/auth/admin.py @@ -167,6 +167,7 @@ class UserAdmin(admin.ModelAdmin): 'form': form, 'is_popup': (IS_POPUP_VAR in request.POST or IS_POPUP_VAR in request.GET), + 'is_popup_var': IS_POPUP_VAR, 'add': True, 'change': False, 'has_delete_permission': False, diff --git a/tests/admin_custom_urls/tests.py b/tests/admin_custom_urls/tests.py index e0c2d4f7466..ebd3291f2c7 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 eef986cb306..3388766104a 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 @@ {% if show_result_count %} - {% blocktranslate count counter=cl.result_count %}{{ counter }} result{% plural %}{{ counter }} results{% endblocktranslate %} ({% 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 %}) + {% blocktranslate count counter=cl.result_count %}{{ counter }} result{% plural %}{{ counter }} results{% endblocktranslate %} ({% 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 %}) {% endif %} {% for pair in cl.params.items %} {% if pair.0 != search_var %}{% endif %} diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index 69fd43ba8f4..880ba0b85f7 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"')