mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-11 08:43:10 +00:00
Use specific page objects on reorder listings with <100 items
This commit is contained in:
parent
a03c310858
commit
7818edf758
2 changed files with 12 additions and 4 deletions
|
|
@ -266,6 +266,12 @@ class TestPageExplorer(TestCase, WagtailTestUtils):
|
|||
response = self.client.get(reverse('wagtailadmin_explore', args=(self.new_event.id, )))
|
||||
self.assertContains(response, 'New event (single event)')
|
||||
|
||||
# Reorder view should also use specific pages
|
||||
# (provided there are <100 pages in the listing, as this may be a significant
|
||||
# performance hit on larger listings)
|
||||
response = self.client.get(reverse('wagtailadmin_explore', args=(self.root_page.id, )) + '?ordering=ord')
|
||||
self.assertContains(response, 'New event (single event)')
|
||||
|
||||
def test_parent_page_is_specific(self):
|
||||
response = self.client.get(reverse('wagtailadmin_explore', args=(self.child_page.id, )))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
|
|
|||
|
|
@ -92,10 +92,12 @@ def index(request, parent_page_id=None):
|
|||
# allow drag-and-drop reordering
|
||||
do_paginate = ordering != 'ord'
|
||||
|
||||
if do_paginate:
|
||||
# Retrieve pages in their most specific form.
|
||||
# Only do this for paginated listings, as this could potentially be a
|
||||
# very expensive operation when performed on a large queryset.
|
||||
if do_paginate or pages.count() < 100:
|
||||
# Retrieve pages in their most specific form, so that custom
|
||||
# get_admin_display_title and get_url_parts methods on subclasses are respected.
|
||||
# However, skip this on unpaginated listings with >100 child pages as this could
|
||||
# be a significant performance hit. (This should only happen on the reorder view,
|
||||
# and hopefully no-one is having to do manual reordering on listings that large...)
|
||||
pages = pages.specific()
|
||||
|
||||
# allow hooks to modify the queryset
|
||||
|
|
|
|||
Loading…
Reference in a new issue