0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-12-01 11:41:20 +01:00

Only show lock message if the request method is GET

This commit is contained in:
Sage Abdullah 2022-12-19 12:03:31 +00:00
parent 9a8b3adc90
commit 7c71a2187f
No known key found for this signature in database
GPG Key ID: EB1A33CC51CC0217
2 changed files with 7 additions and 7 deletions

View File

@ -540,10 +540,11 @@ class CreateEditViewOptionalFeaturesMixin:
"user_can_unlock": user_can_unlock,
}
if not self.lock:
# Do not add lock message if the request method is not GET,
# as POST request may add success/validation error messages already
if not self.lock or self.request.method != "GET":
return context
# Only add lock message if the request method is GET
lock_message = self.lock.get_message(self.request.user)
if lock_message:
if user_can_unlock:

View File

@ -3146,11 +3146,10 @@ class TestScheduledForPublishLock(BaseTestSnippetEditView):
count=1,
)
# Should show the lock message
self.assertContains(
# Should not show the lock message, as we already have the error message
self.assertNotContains(
response,
"Draft state model 'I've been edited!' is locked and has been scheduled to go live at",
count=1,
)
# Should show the lock information in the status side panel
@ -3171,7 +3170,7 @@ class TestScheduledForPublishLock(BaseTestSnippetEditView):
allow_extra_attrs=True,
)
# Should show button to cancel scheduled publishing
# Should not show button to cancel scheduled publishing as the lock message isn't shown
unschedule_url = reverse(
"wagtailsnippets_tests_draftstatemodel:revisions_unschedule",
args=[self.test_snippet.pk, self.latest_revision.pk],
@ -3179,7 +3178,7 @@ class TestScheduledForPublishLock(BaseTestSnippetEditView):
self.assertTagInHTML(
f'<button data-action="w-action#post" data-controller="w-action" data-w-action-url-value="{unschedule_url}">Cancel scheduled publish</button>',
html,
count=1,
count=0,
allow_extra_attrs=True,
)