From 8a3304c147c40350aaa9d0df2121b9a45e130ab1 Mon Sep 17 00:00:00 2001 From: Ryan Pineo Date: Sat, 3 Oct 2015 10:27:59 -0400 Subject: [PATCH] Fix page edit publish "View Live" url --- wagtail/wagtailadmin/tests/test_pages_views.py | 9 +++++++-- wagtail/wagtailadmin/views/pages.py | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/wagtail/wagtailadmin/tests/test_pages_views.py b/wagtail/wagtailadmin/tests/test_pages_views.py index 41cac0c6d..286eb5058 100644 --- a/wagtail/wagtailadmin/tests/test_pages_views.py +++ b/wagtail/wagtailadmin/tests/test_pages_views.py @@ -671,10 +671,10 @@ class TestPageEdit(TestCase, WagtailTestUtils): post_data = { 'title': "I've been edited!", 'content': "Some content", - 'slug': 'hello-world', + 'slug': 'hello-world-new', 'action-publish': "Publish", } - response = self.client.post(reverse('wagtailadmin_pages:edit', args=(self.child_page.id, )), post_data) + response = self.client.post(reverse('wagtailadmin_pages:edit', args=(self.child_page.id, )), post_data, follow=True) # Should be redirected to explorer self.assertRedirects(response, reverse('wagtailadmin_explore', args=(self.root_page.id, ))) @@ -697,6 +697,11 @@ class TestPageEdit(TestCase, WagtailTestUtils): # first_published_at should not change as it was already set self.assertEqual(first_published_at, child_page_new.first_published_at) + # The "View Live" button should have the updated slug. + for message in response.context['messages']: + self.assertIn('hello-world-new', message.message) + break + def test_edit_post_publish_scheduled(self): go_live_at = timezone.now() + timedelta(days=1) expire_at = timezone.now() + timedelta(days=2) diff --git a/wagtail/wagtailadmin/views/pages.py b/wagtail/wagtailadmin/views/pages.py index f774b9e5e..2fb3db859 100644 --- a/wagtail/wagtailadmin/views/pages.py +++ b/wagtail/wagtailadmin/views/pages.py @@ -251,6 +251,9 @@ def edit(request, page_id): # Publish if is_publishing: revision.publish() + # Need to reload the page because the url has changed and we + # need access to it for the "View Live" button. + page = Page.objects.get(pk=page.pk) # Notifications if is_publishing: