Refs #25165 -- Fixed JSON serialization for delete popup in the admin.
This commit is contained in:
parent
8715205c5c
commit
3541ca1504
|
@ -1319,7 +1319,7 @@ class ModelAdmin(BaseModelAdmin):
|
|||
if IS_POPUP_VAR in request.POST:
|
||||
popup_response_data = json.dumps({
|
||||
'action': 'delete',
|
||||
'value': obj_id,
|
||||
'value': str(obj_id),
|
||||
})
|
||||
return SimpleTemplateResponse('admin/popup_response.html', {
|
||||
'popup_response_data': popup_response_data,
|
||||
|
|
|
@ -968,4 +968,4 @@ class ParentWithUUIDPK(models.Model):
|
|||
|
||||
|
||||
class RelatedWithUUIDPKModel(models.Model):
|
||||
parent = models.ForeignKey(ParentWithUUIDPK, on_delete=models.CASCADE)
|
||||
parent = models.ForeignKey(ParentWithUUIDPK, on_delete=models.SET_NULL, null=True, blank=True)
|
||||
|
|
|
@ -4546,6 +4546,23 @@ class SeleniumAdminViewsFirefoxTests(AdminSeleniumWebDriverTestCase):
|
|||
self.assertEqual(select.first_selected_option.text, uuid_id)
|
||||
self.assertEqual(select.first_selected_option.get_attribute('value'), uuid_id)
|
||||
|
||||
def test_inline_uuid_pk_delete_with_popup(self):
|
||||
from selenium.webdriver.support.ui import Select
|
||||
parent = ParentWithUUIDPK.objects.create(title='test')
|
||||
related_with_parent = RelatedWithUUIDPKModel.objects.create(parent=parent)
|
||||
self.admin_login(username='super', password='secret', login_url=reverse('admin:index'))
|
||||
change_url = reverse('admin:admin_views_relatedwithuuidpkmodel_change', args=(related_with_parent.id,))
|
||||
self.selenium.get(self.live_server_url + change_url)
|
||||
self.selenium.find_element_by_id('delete_id_parent').click()
|
||||
self.wait_for_popup()
|
||||
self.selenium.switch_to.window(self.selenium.window_handles[-1])
|
||||
self.selenium.find_element_by_xpath('//input[@value="Yes, I\'m sure"]').click()
|
||||
self.selenium.switch_to.window(self.selenium.window_handles[0])
|
||||
select = Select(self.selenium.find_element_by_id('id_parent'))
|
||||
self.assertEqual(ParentWithUUIDPK.objects.count(), 0)
|
||||
self.assertEqual(select.first_selected_option.text, '---------')
|
||||
self.assertEqual(select.first_selected_option.get_attribute('value'), '')
|
||||
|
||||
|
||||
class SeleniumAdminViewsChromeTests(SeleniumAdminViewsFirefoxTests):
|
||||
webdriver_class = 'selenium.webdriver.chrome.webdriver.WebDriver'
|
||||
|
|
Loading…
Reference in New Issue