Use specific page when choosing a title

Especially useful in RichText blocks when choosing an internal link that overrides Page url / title functionality
pull/3495/merge
Gary Krige 2017-03-06 17:46:57 +02:00 zatwierdzone przez Matt Westcott
rodzic 22617e95a7
commit 162b29b6ed
2 zmienionych plików z 23 dodań i 2 usunięć

Wyświetl plik

@ -4,7 +4,7 @@ from django.core.urlresolvers import reverse
from django.test import TestCase
from django.utils.http import urlencode
from wagtail.tests.testapp.models import EventIndex, EventPage, SimplePage
from wagtail.tests.testapp.models import EventIndex, EventPage, SimplePage, SingleEventPage
from wagtail.tests.utils import WagtailTestUtils
from wagtail.wagtailcore.models import Page
@ -132,6 +132,27 @@ class TestChooserBrowseChild(TestCase, WagtailTestUtils):
self.assertFalse(pages[event_index_page.id].can_choose)
self.assertTrue(pages[event_index_page.id].can_descend)
def test_with_url_extended_page_type(self):
# Add a page that overrides the url path
single_event_page = SingleEventPage(
title="foo",
location='the moon', audience='public',
cost='free', date_from='2001-01-01',
)
self.root_page.add_child(instance=single_event_page)
# Send request
response = self.get()
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'wagtailadmin/chooser/browse.html')
page_urls = [
page.url
for page in response.context['pages']
]
self.assertIn('/foo/pointless-suffix/', page_urls)
def test_with_blank_page_type(self):
# a blank page_type parameter should be equivalent to an absent parameter
# (or an explicit page_type of wagtailcore.page)

Wyświetl plik

@ -74,7 +74,7 @@ def browse(request, parent_page_id=None):
parent_page = all_desired_pages.first_common_ancestor()
# Get children of parent page
pages = parent_page.get_children()
pages = parent_page.get_children().specific()
# allow hooks to modify the queryset
for hook in hooks.get_hooks('construct_page_chooser_queryset'):