Fixed #32771 -- Used IS_POPUP_VAR constant instead of hard-coded value.
This commit is contained in:
parent
6e155d280d
commit
2978c63a34
|
@ -19,7 +19,7 @@
|
||||||
<form{% if form_url %} action="{{ form_url }}"{% endif %} method="post" id="{{ opts.model_name }}_form">{% csrf_token %}{% block form_top %}{% endblock %}
|
<form{% if form_url %} action="{{ form_url }}"{% endif %} method="post" id="{{ opts.model_name }}_form">{% csrf_token %}{% block form_top %}{% endblock %}
|
||||||
<input type="text" name="username" value="{{ original.get_username }}" class="hidden">
|
<input type="text" name="username" value="{{ original.get_username }}" class="hidden">
|
||||||
<div>
|
<div>
|
||||||
{% if is_popup %}<input type="hidden" name="_popup" value="1">{% endif %}
|
{% if is_popup %}<input type="hidden" name="{{ is_popup_var }}" value="1">{% endif %}
|
||||||
{% if form.errors %}
|
{% if form.errors %}
|
||||||
<p class="errornote">
|
<p class="errornote">
|
||||||
{% if form.errors.items|length == 1 %}{% translate "Please correct the error below." %}{% else %}{% translate "Please correct the errors below." %}{% endif %}
|
{% if form.errors.items|length == 1 %}{% translate "Please correct the error below." %}{% else %}{% translate "Please correct the errors below." %}{% endif %}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<input type="text" size="40" name="{{ search_var }}" value="{{ cl.query }}" id="searchbar" autofocus>
|
<input type="text" size="40" name="{{ search_var }}" value="{{ cl.query }}" id="searchbar" autofocus>
|
||||||
<input type="submit" value="{% translate 'Search' %}">
|
<input type="submit" value="{% translate 'Search' %}">
|
||||||
{% if show_result_count %}
|
{% 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 %}
|
{% endif %}
|
||||||
{% for pair in cl.params.items %}
|
{% for pair in cl.params.items %}
|
||||||
{% if pair.0 != search_var %}<input type="hidden" name="{{ pair.0 }}" value="{{ pair.1 }}">{% endif %}
|
{% if pair.0 != search_var %}<input type="hidden" name="{{ pair.0 }}" value="{{ pair.1 }}">{% endif %}
|
||||||
|
|
|
@ -6,7 +6,7 @@ from django.contrib.admin.utils import (
|
||||||
label_for_field, lookup_field,
|
label_for_field, lookup_field,
|
||||||
)
|
)
|
||||||
from django.contrib.admin.views.main import (
|
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.core.exceptions import ObjectDoesNotExist
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
@ -423,7 +423,8 @@ def search_form(cl):
|
||||||
return {
|
return {
|
||||||
'cl': cl,
|
'cl': cl,
|
||||||
'show_result_count': cl.result_count != cl.full_result_count,
|
'show_result_count': cl.result_count != cl.full_result_count,
|
||||||
'search_var': SEARCH_VAR
|
'search_var': SEARCH_VAR,
|
||||||
|
'is_popup_var': IS_POPUP_VAR,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -167,6 +167,7 @@ class UserAdmin(admin.ModelAdmin):
|
||||||
'form': form,
|
'form': form,
|
||||||
'is_popup': (IS_POPUP_VAR in request.POST or
|
'is_popup': (IS_POPUP_VAR in request.POST or
|
||||||
IS_POPUP_VAR in request.GET),
|
IS_POPUP_VAR in request.GET),
|
||||||
|
'is_popup_var': IS_POPUP_VAR,
|
||||||
'add': True,
|
'add': True,
|
||||||
'change': False,
|
'change': False,
|
||||||
'has_delete_permission': False,
|
'has_delete_permission': False,
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from django.contrib.admin.utils import quote
|
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.contrib.auth.models import User
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
from django.test import TestCase, override_settings
|
from django.test import TestCase, override_settings
|
||||||
|
@ -58,7 +59,7 @@ class AdminCustomUrlsTest(TestCase):
|
||||||
Ensure POST on add_view works.
|
Ensure POST on add_view works.
|
||||||
"""
|
"""
|
||||||
post_data = {
|
post_data = {
|
||||||
'_popup': '1',
|
IS_POPUP_VAR: '1',
|
||||||
"name": 'Action added through a popup',
|
"name": 'Action added through a popup',
|
||||||
"description": "Description of added action",
|
"description": "Description of added action",
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<input type="text" size="40" name="{{ search_var }}" value="{{ cl.query }}" id="searchbar" autofocus />
|
<input type="text" size="40" name="{{ search_var }}" value="{{ cl.query }}" id="searchbar" autofocus />
|
||||||
<input type="submit" value="{% translate 'Search' %}" />
|
<input type="submit" value="{% translate 'Search' %}" />
|
||||||
{% if show_result_count %}
|
{% 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 %}
|
{% endif %}
|
||||||
{% for pair in cl.params.items %}
|
{% for pair in cl.params.items %}
|
||||||
{% if pair.0 != search_var %}<input type="hidden" name="{{ pair.0 }}" value="{{ pair.1 }}"/>{% endif %}
|
{% if pair.0 != search_var %}<input type="hidden" name="{{ pair.0 }}" value="{{ pair.1 }}"/>{% endif %}
|
||||||
|
|
|
@ -293,7 +293,7 @@ class AdminViewBasicTest(AdminViewBasicTestCase):
|
||||||
Ensure http response from a popup is properly escaped.
|
Ensure http response from a popup is properly escaped.
|
||||||
"""
|
"""
|
||||||
post_data = {
|
post_data = {
|
||||||
'_popup': '1',
|
IS_POPUP_VAR: '1',
|
||||||
'title': 'title with a new\nline',
|
'title': 'title with a new\nline',
|
||||||
'content': 'some content',
|
'content': 'some content',
|
||||||
'date_0': '2010-09-10',
|
'date_0': '2010-09-10',
|
||||||
|
@ -5391,17 +5391,17 @@ class UserAdminTest(TestCase):
|
||||||
response = self.client.get(reverse('admin:admin_views_album_add'))
|
response = self.client.get(reverse('admin:admin_views_album_add'))
|
||||||
self.assertContains(response, reverse('admin:auth_user_add'))
|
self.assertContains(response, reverse('admin:auth_user_add'))
|
||||||
self.assertContains(response, 'class="related-widget-wrapper-link add-related" id="add_id_owner"')
|
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="_continue"')
|
||||||
self.assertNotContains(response, 'name="_addanother"')
|
self.assertNotContains(response, 'name="_addanother"')
|
||||||
data = {
|
data = {
|
||||||
'username': 'newuser',
|
'username': 'newuser',
|
||||||
'password1': 'newpassword',
|
'password1': 'newpassword',
|
||||||
'password2': 'newpassword',
|
'password2': 'newpassword',
|
||||||
'_popup': '1',
|
IS_POPUP_VAR: '1',
|
||||||
'_save': '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"')
|
self.assertContains(response, '"obj": "newuser"')
|
||||||
|
|
||||||
def test_user_fk_change_popup(self):
|
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, reverse('admin:auth_user_change', args=('__fk__',)))
|
||||||
self.assertContains(response, 'class="related-widget-wrapper-link change-related" id="change_id_owner"')
|
self.assertContains(response, 'class="related-widget-wrapper-link change-related" id="change_id_owner"')
|
||||||
user = User.objects.get(username='changeuser')
|
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)
|
response = self.client.get(url)
|
||||||
self.assertNotContains(response, 'name="_continue"')
|
self.assertNotContains(response, 'name="_continue"')
|
||||||
self.assertNotContains(response, 'name="_addanother"')
|
self.assertNotContains(response, 'name="_addanother"')
|
||||||
|
@ -5422,7 +5422,7 @@ class UserAdminTest(TestCase):
|
||||||
'last_login_1': '13:20:10',
|
'last_login_1': '13:20:10',
|
||||||
'date_joined_0': '2007-05-30',
|
'date_joined_0': '2007-05-30',
|
||||||
'date_joined_1': '13:20:10',
|
'date_joined_1': '13:20:10',
|
||||||
'_popup': '1',
|
IS_POPUP_VAR: '1',
|
||||||
'_save': '1',
|
'_save': '1',
|
||||||
}
|
}
|
||||||
response = self.client.post(url, data, follow=True)
|
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, reverse('admin:auth_user_delete', args=('__fk__',)))
|
||||||
self.assertContains(response, 'class="related-widget-wrapper-link change-related" id="change_id_owner"')
|
self.assertContains(response, 'class="related-widget-wrapper-link change-related" id="change_id_owner"')
|
||||||
user = User.objects.get(username='changeuser')
|
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)
|
response = self.client.get(url)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
data = {
|
data = {
|
||||||
'post': 'yes',
|
'post': 'yes',
|
||||||
'_popup': '1',
|
IS_POPUP_VAR: '1',
|
||||||
}
|
}
|
||||||
response = self.client.post(url, data, follow=True)
|
response = self.client.post(url, data, follow=True)
|
||||||
self.assertContains(response, '"action": "delete"')
|
self.assertContains(response, '"action": "delete"')
|
||||||
|
|
Loading…
Reference in New Issue