From 100d213b00f59bd9cf5124fa552ebf250610c577 Mon Sep 17 00:00:00 2001 From: Sage Abdullah Date: Thu, 15 Dec 2022 09:21:51 +0000 Subject: [PATCH] Fix page unlock message Regression in ddbdd51 --- wagtail/admin/tests/pages/test_page_locking.py | 13 +++++++++++++ wagtail/admin/views/pages/lock.py | 7 +++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/wagtail/admin/tests/pages/test_page_locking.py b/wagtail/admin/tests/pages/test_page_locking.py index b3cf5ef2dc..3b92c0d1ea 100644 --- a/wagtail/admin/tests/pages/test_page_locking.py +++ b/wagtail/admin/tests/pages/test_page_locking.py @@ -2,6 +2,7 @@ from django.contrib.auth.models import Group, Permission from django.test import TestCase from django.urls import reverse from django.utils import timezone +from django.utils.html import escape from wagtail.models import Page from wagtail.test.testapp.models import SimplePage @@ -227,6 +228,7 @@ class TestLocking(TestCase, WagtailTestUtils): response = self.client.post( reverse("wagtailadmin_pages:unlock", args=(self.child_page.id,)), {"next": reverse("wagtailadmin_pages:edit", args=(self.child_page.id,))}, + follow=True, ) # Check response @@ -234,6 +236,17 @@ class TestLocking(TestCase, WagtailTestUtils): response, reverse("wagtailadmin_pages:edit", args=(self.child_page.id,)) ) + # Should show unlocked message + self.assertContains( + response, escape("Page 'Hello world! (simple page)' is now unlocked.") + ) + + # Message shouldn't be wrapped in a tuple + self.assertNotContains( + response, + escape(("Page 'Hello world! (simple page)' is now unlocked.",)), + ) + # Check that the page is unlocked page = Page.objects.get(id=self.child_page.id) self.assertFalse(page.locked) diff --git a/wagtail/admin/views/pages/lock.py b/wagtail/admin/views/pages/lock.py index 2a83838c27..92dc41b45d 100644 --- a/wagtail/admin/views/pages/lock.py +++ b/wagtail/admin/views/pages/lock.py @@ -33,7 +33,6 @@ class UnlockView(PageOperationViewMixin, lock.UnlockView): return super().perform_operation() def get_success_message(self): - return ( - _("Page '%(page_title)s' is now unlocked.") - % {"page_title": self.object.get_admin_display_title()}, - ) + return _("Page '%(page_title)s' is now unlocked.") % { + "page_title": self.object.get_admin_display_title() + }