Maintain the 'next' GET argument through the add_subpage workflow.

Every other Page workflow seems to maintain this argument, to ensure that the
user ends up back at the page they were on when they started. This patch enables
the add_subpage workflow to do the same.
pull/3203/merge
Robert Rollins 2016-12-16 17:26:53 -08:00 zatwierdzone przez Matt Westcott
rodzic 29645c0f6a
commit fab11259bc
5 zmienionych plików z 17 dodań i 1 usunięć

Wyświetl plik

@ -9,6 +9,7 @@ Changelog
* Added `before_copy_page` and `after_copy_page` hooks (Matheus Bratfisch)
* View live / draft links in the admin now consistently open in a new window (Marco Fucci)
* `ChoiceBlock` now omits the blank option if the block is required and has a default value (Andreas Nüßlein)
* The `add_subpage` view now maintains a `next` URL parameter to specify where to redirect to after completing page creation (Robert Rollins)
* Fix: Help text for StreamField is now visible and does not cover block controls (Stein Strindhaug)
* Fix: "X minutes ago" timestamps are now marked for translation (Janneke Janssen, Matt Westcott)

Wyświetl plik

@ -28,6 +28,7 @@ Other features
* Added :ref:`before_copy_page` and :ref:`after_copy_page` hooks (Matheus Bratfisch)
* View live / draft links in the admin now consistently open in a new window (Marco Fucci)
* ``ChoiceBlock`` now omits the blank option if the block is required and has a default value (Andreas Nüßlein)
* The ``add_subpage`` view now maintains a ``next`` URL parameter to specify where to redirect to after completing page creation (Robert Rollins)
Bug fixes

Wyświetl plik

@ -17,7 +17,7 @@
<li>
<div class="row row-flush">
<div class="col6">
<a href="{% url 'wagtailadmin_pages:add' app_label model_name parent_page.id %}" class="icon icon-plus-inverse icon-larger">{{ verbose_name }}</a>
<a href="{% url 'wagtailadmin_pages:add' app_label model_name parent_page.id %}{% if next %}?next={{ next }}{% endif %}" class="icon icon-plus-inverse icon-larger">{{ verbose_name }}</a>
</div>
<small class="col6" style="text-align:right">

Wyświetl plik

@ -421,6 +421,8 @@ class TestPageCreation(TestCase, WagtailTestUtils):
self.assertEqual(response.status_code, 200)
self.assertContains(response, "Simple page")
target_url = reverse('wagtailadmin_pages:add', args=('tests', 'simplepage', self.root_page.id))
self.assertContains(response, 'href="%s"' % target_url)
# List of available page types should not contain pages with is_creatable = False
self.assertNotContains(response, "MTI base page")
# List of available page types should not contain abstract pages
@ -481,6 +483,17 @@ class TestPageCreation(TestCase, WagtailTestUtils):
response = self.client.get(reverse('wagtailadmin_pages:add_subpage', args=(100000, )))
self.assertEqual(response.status_code, 404)
def test_add_subpage_with_next_param(self):
response = self.client.get(
reverse('wagtailadmin_pages:add_subpage', args=(self.root_page.id, )),
{'next': '/admin/users/'}
)
self.assertEqual(response.status_code, 200)
self.assertContains(response, "Simple page")
target_url = reverse('wagtailadmin_pages:add', args=('tests', 'simplepage', self.root_page.id))
self.assertContains(response, 'href="%s?next=/admin/users/"' % target_url)
def test_create_simplepage(self):
response = self.client.get(reverse('wagtailadmin_pages:add', args=('tests', 'simplepage', self.root_page.id)))
self.assertEqual(response.status_code, 200)

Wyświetl plik

@ -127,6 +127,7 @@ def add_subpage(request, parent_page_id):
return render(request, 'wagtailadmin/pages/add_subpage.html', {
'parent_page': parent_page,
'page_types': page_types,
'next': get_valid_next_url_from_request(request),
})