kopia lustrzana https://github.com/wagtail/wagtail
Update restriction message when switched to public
rodzic
e2e0130662
commit
95877836dd
wagtail
|
@ -197,6 +197,18 @@ class TestSetPrivacyView(WagtailTestUtils, TestCase):
|
|||
PageViewRestriction.objects.filter(page=self.private_page).exists()
|
||||
)
|
||||
|
||||
history_url = reverse(
|
||||
"wagtailadmin_pages:history", kwargs={"page_id": self.private_page.id}
|
||||
)
|
||||
history_response = self.client.get(history_url)
|
||||
|
||||
# Check that the expected log message is present
|
||||
expected_log_message = "Removed the 'Private, accessible with the following password' view restriction. The page is public."
|
||||
self.assertContains(
|
||||
history_response,
|
||||
expected_log_message,
|
||||
)
|
||||
|
||||
def test_get_private_groups(self):
|
||||
"""
|
||||
This tests that the restriction type and group fields as set correctly when a user opens the set_privacy view on a public page
|
||||
|
|
|
@ -3525,10 +3525,12 @@ class PageViewRestriction(BaseViewRestriction):
|
|||
"""
|
||||
Custom delete handler to aid in logging
|
||||
:param user: the user removing the view restriction
|
||||
:param specific_instance: the specific model instance the restriction applies to
|
||||
"""
|
||||
specific_instance = self.page.specific
|
||||
if specific_instance:
|
||||
removed_restriction_type = PageViewRestriction.objects.filter(
|
||||
id=self.id
|
||||
).values_list("restriction_type", flat=True)[0]
|
||||
log(
|
||||
instance=specific_instance,
|
||||
action="wagtail.view_restriction.delete",
|
||||
|
@ -3537,7 +3539,7 @@ class PageViewRestriction(BaseViewRestriction):
|
|||
"restriction": {
|
||||
"type": self.restriction_type,
|
||||
"title": force_str(
|
||||
dict(self.RESTRICTION_CHOICES).get(self.restriction_type)
|
||||
dict(self.RESTRICTION_CHOICES).get(removed_restriction_type)
|
||||
),
|
||||
}
|
||||
},
|
||||
|
|
|
@ -339,7 +339,9 @@ def register_core_log_actions(actions):
|
|||
|
||||
def format_message(self, log_entry):
|
||||
try:
|
||||
return _("Removed the '%(restriction)s' view restriction") % {
|
||||
return _(
|
||||
"Removed the '%(restriction)s' view restriction. The page is public."
|
||||
) % {
|
||||
"restriction": log_entry.data["restriction"]["title"],
|
||||
}
|
||||
except KeyError:
|
||||
|
|
Ładowanie…
Reference in New Issue