kopia lustrzana https://github.com/wagtail/wagtail
Pass all URL parameters to page chooser search action, including multiple and user_perms
rodzic
c2676af857
commit
8da1796d53
|
@ -5,7 +5,8 @@
|
|||
{% trans "Choose a page" as choose_str %}
|
||||
{% endif %}
|
||||
|
||||
{% include "wagtailadmin/shared/header.html" with title=choose_str subtitle=page_type_names|join:", " search_url="wagtailadmin_choose_page_search" query_parameters="page_type="|add:page_type_string icon="doc-empty-inverse" search_disable_async=True %}
|
||||
{% querystring as search_query_params %}
|
||||
{% include "wagtailadmin/shared/header.html" with title=choose_str subtitle=page_type_names|join:", " search_url="wagtailadmin_choose_page_search" query_parameters=search_query_params icon="doc-empty-inverse" search_disable_async=True %}
|
||||
|
||||
<div class="nice-padding">
|
||||
{% include 'wagtailadmin/chooser/_link_types.html' with current='internal' %}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
- `search_results_url` - URL to be used for async requests to search results, if not provided, the form's action URL will be used
|
||||
- `search_target` - A selector string to be used as the target for the search results to be swapped into. Defaults to '#listing-results'
|
||||
- `search_disable_async` - If True, the default header async search functionality will not be used
|
||||
- `query_parameters` - a query string (without the '?') to be placed after the search URL
|
||||
- `query_parameters` - a query string (with or without the '?') to be placed after the search URL
|
||||
- `icon` - name of an icon to place against the title
|
||||
- `merged` - if true, add the classname 'w-header--merged'
|
||||
- `action_url` - if present, display an 'action' button. This is the URL to be used as the link URL for the button
|
||||
|
@ -42,7 +42,7 @@
|
|||
{% if search_url %}
|
||||
<form
|
||||
class="col search-form"
|
||||
action="{% url search_url %}{% if query_parameters %}?{{ query_parameters }}{% endif %}"
|
||||
action="{% url search_url %}{% if query_parameters %}{% if query_parameters.0 != '?' %}?{% endif %}{{ query_parameters }}{% endif %}"
|
||||
method="get"
|
||||
novalidate
|
||||
role="search"
|
||||
|
|
|
@ -65,12 +65,20 @@ class TestChooserBrowse(WagtailTestUtils, TestCase):
|
|||
|
||||
checkbox_value = str(self.child_page.id)
|
||||
decoded_content = response.content.decode()
|
||||
response_json = json.loads(decoded_content)
|
||||
self.assertEqual(response_json["step"], "browse")
|
||||
response_html = response_json["html"]
|
||||
|
||||
self.assertIn(f'value=\\"{checkbox_value}\\"', decoded_content)
|
||||
self.assertIn(f'value="{checkbox_value}"', response_html)
|
||||
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertTemplateUsed(response, "wagtailadmin/chooser/browse.html")
|
||||
|
||||
soup = self.get_soup(response_html)
|
||||
search_url = soup.find("form", role="search")["action"]
|
||||
search_query_params = parse_qs(urlsplit(search_url).query)
|
||||
self.assertEqual(search_query_params["multiple"], ["1"])
|
||||
|
||||
@override_settings(USE_THOUSAND_SEPARATOR=False)
|
||||
def test_multiple_chooser_view_without_thousand_separator(self):
|
||||
self.page = Page.objects.get(id=1)
|
||||
|
|
Ładowanie…
Reference in New Issue