mirror of
https://github.com/django/django.git
synced 2025-01-03 15:06:09 +00:00
Refs #25165 -- Fixed failure of admin's "Add another" popup to close.
Thanks Thomas Grainger for the fix.
This commit is contained in:
parent
db8f462494
commit
822a03b3e4
@ -1083,7 +1083,7 @@ class ModelAdmin(BaseModelAdmin):
|
|||||||
attr = obj._meta.pk.attname
|
attr = obj._meta.pk.attname
|
||||||
value = obj.serializable_value(attr)
|
value = obj.serializable_value(attr)
|
||||||
popup_response_data = json.dumps({
|
popup_response_data = json.dumps({
|
||||||
'value': value,
|
'value': six.text_type(value),
|
||||||
'obj': six.text_type(obj),
|
'obj': six.text_type(obj),
|
||||||
})
|
})
|
||||||
return SimpleTemplateResponse('admin/popup_response.html', {
|
return SimpleTemplateResponse('admin/popup_response.html', {
|
||||||
|
@ -16,6 +16,7 @@ from django.db import models
|
|||||||
from django.utils.encoding import python_2_unicode_compatible
|
from django.utils.encoding import python_2_unicode_compatible
|
||||||
|
|
||||||
|
|
||||||
|
@python_2_unicode_compatible
|
||||||
class Section(models.Model):
|
class Section(models.Model):
|
||||||
"""
|
"""
|
||||||
A simple section that links to articles, to test linking to related items
|
A simple section that links to articles, to test linking to related items
|
||||||
@ -23,6 +24,9 @@ class Section(models.Model):
|
|||||||
"""
|
"""
|
||||||
name = models.CharField(max_length=100)
|
name = models.CharField(max_length=100)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name_property(self):
|
def name_property(self):
|
||||||
"""
|
"""
|
||||||
|
@ -4481,8 +4481,10 @@ class SeleniumAdminViewsFirefoxTests(AdminSeleniumWebDriverTestCase):
|
|||||||
"""
|
"""
|
||||||
list_editable foreign keys have add/change popups.
|
list_editable foreign keys have add/change popups.
|
||||||
"""
|
"""
|
||||||
|
from selenium.webdriver.support.ui import Select
|
||||||
s1 = Section.objects.create(name='Test section')
|
s1 = Section.objects.create(name='Test section')
|
||||||
Article.objects.create(
|
Article.objects.create(
|
||||||
|
title='foo',
|
||||||
content='<p>Middle content</p>',
|
content='<p>Middle content</p>',
|
||||||
date=datetime.datetime(2008, 3, 18, 11, 54, 58),
|
date=datetime.datetime(2008, 3, 18, 11, 54, 58),
|
||||||
section=s1,
|
section=s1,
|
||||||
@ -4494,16 +4496,24 @@ class SeleniumAdminViewsFirefoxTests(AdminSeleniumWebDriverTestCase):
|
|||||||
self.wait_for_popup()
|
self.wait_for_popup()
|
||||||
self.selenium.switch_to.window(self.selenium.window_handles[-1])
|
self.selenium.switch_to.window(self.selenium.window_handles[-1])
|
||||||
self.wait_for_text('#content h1', 'Change section')
|
self.wait_for_text('#content h1', 'Change section')
|
||||||
self.selenium.close()
|
name_input = self.selenium.find_element_by_id('id_name')
|
||||||
|
name_input.clear()
|
||||||
|
name_input.send_keys('edited section')
|
||||||
|
self.selenium.find_element_by_xpath('//input[@value="Save"]').click()
|
||||||
self.selenium.switch_to.window(self.selenium.window_handles[0])
|
self.selenium.switch_to.window(self.selenium.window_handles[0])
|
||||||
|
select = Select(self.selenium.find_element_by_id('id_form-0-section'))
|
||||||
|
self.assertEqual(select.first_selected_option.text, 'edited section')
|
||||||
|
|
||||||
# Add popup
|
# Add popup
|
||||||
self.selenium.find_element_by_id('add_id_form-0-section').click()
|
self.selenium.find_element_by_id('add_id_form-0-section').click()
|
||||||
self.wait_for_popup()
|
self.wait_for_popup()
|
||||||
self.selenium.switch_to.window(self.selenium.window_handles[-1])
|
self.selenium.switch_to.window(self.selenium.window_handles[-1])
|
||||||
self.wait_for_text('#content h1', 'Add section')
|
self.wait_for_text('#content h1', 'Add section')
|
||||||
self.selenium.close()
|
self.selenium.find_element_by_id('id_name').send_keys('new section')
|
||||||
|
self.selenium.find_element_by_xpath('//input[@value="Save"]').click()
|
||||||
self.selenium.switch_to.window(self.selenium.window_handles[0])
|
self.selenium.switch_to.window(self.selenium.window_handles[0])
|
||||||
|
select = Select(self.selenium.find_element_by_id('id_form-0-section'))
|
||||||
|
self.assertEqual(select.first_selected_option.text, 'new section')
|
||||||
|
|
||||||
|
|
||||||
class SeleniumAdminViewsChromeTests(SeleniumAdminViewsFirefoxTests):
|
class SeleniumAdminViewsChromeTests(SeleniumAdminViewsFirefoxTests):
|
||||||
|
Loading…
Reference in New Issue
Block a user