Fixed #26387 -- Restored the functionality of the admin's raw_id_fields in list_editable.

This commit is contained in:
Tim Graham 2016-03-24 16:22:35 -04:00
parent 8550566af6
commit acfaec3db5
6 changed files with 39 additions and 8 deletions

View File

@ -162,6 +162,14 @@
}
});
$('.related-widget-wrapper select').trigger('change');
$('.related-lookup').click(function(e) {
e.preventDefault();
var event = $.Event('django:lookup-related');
$(this).trigger(event);
if (!event.isDefaultPrevented()) {
showRelatedObjectLookupPopup(this);
}
});
});
})(django.jQuery);

View File

@ -12,14 +12,6 @@
showAddAnotherPopup(this);
}
});
$('.related-lookup').click(function(e) {
e.preventDefault();
var event = $.Event('django:lookup-related');
$(this).trigger(event);
if (!event.isDefaultPrevented()) {
showRelatedObjectLookupPopup(this);
}
});
if (modelName) {
$('form#' + modelName + '_form :input:visible:enabled:first').focus();

View File

@ -15,3 +15,6 @@ Bugfixes
* Fixed data loss on SQLite where ``DurationField`` values with fractional
seconds could be saved as ``None`` (:ticket:`26324`).
* Restored the functionality of the admin's ``raw_id_fields`` in
``list_editable`` (:ticket:`26387`).

View File

@ -37,3 +37,6 @@ Bugfixes
* Fixed a regression in ``CommonMiddleware`` that caused spurious warnings in
logs on requests missing a trailing slash (:ticket:`26293`).
* Restored the functionality of the admin's ``raw_id_fields`` in
``list_editable`` (:ticket:`26387`).

View File

@ -1007,5 +1007,13 @@ site.register(Group, GroupAdmin)
site2 = admin.AdminSite(name="namespaced_admin")
site2.register(User, UserAdmin)
site2.register(Group, GroupAdmin)
site2.register(ParentWithUUIDPK)
site2.register(
RelatedWithUUIDPKModel,
list_display=['pk', 'parent'],
list_editable=['parent'],
raw_id_fields=['parent'],
)
site7 = admin.AdminSite(name="admin7")
site7.register(Article, ArticleAdmin2)

View File

@ -4453,6 +4453,23 @@ class SeleniumTests(AdminSeleniumTestCase):
self.assertEqual(select.first_selected_option.text, '---------')
self.assertEqual(select.first_selected_option.get_attribute('value'), '')
def test_list_editable_raw_id_fields(self):
parent = ParentWithUUIDPK.objects.create(title='test')
parent2 = ParentWithUUIDPK.objects.create(title='test2')
RelatedWithUUIDPKModel.objects.create(parent=parent)
self.admin_login(username='super', password='secret', login_url=reverse('admin:index'))
change_url = reverse('admin:admin_views_relatedwithuuidpkmodel_changelist', current_app=site2.name)
self.selenium.get(self.live_server_url + change_url)
self.selenium.find_element_by_id('lookup_id_form-0-parent').click()
self.wait_for_popup()
self.selenium.switch_to.window(self.selenium.window_handles[-1])
# Select "parent2" in the popup.
self.selenium.find_element_by_link_text(str(parent2.pk)).click()
self.selenium.switch_to.window(self.selenium.window_handles[0])
# The newly selected pk should appear in the raw id input.
value = self.selenium.find_element_by_id('id_form-0-parent').get_attribute('value')
self.assertEqual(value, str(parent2.pk))
@override_settings(ROOT_URLCONF='admin_views.urls')
class ReadonlyTest(AdminFieldExtractionMixin, TestCase):