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:
parent
9a8b3adc90
commit
7c71a2187f
@ -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:
|
||||
|
@ -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,
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user