Use the correct action log when creating a redirect

pull/11080/head
Thibaud Colas 2023-10-18 23:28:22 -04:00
rodzic 3df622f2ef
commit 3376060ea6
4 zmienionych plików z 11 dodań i 3 usunięć

Wyświetl plik

@ -69,6 +69,7 @@ Changelog
* Fix: Avoid forgotten password link text conflicting with the supplied aria-label (Thibaud Colas)
* Fix: Fix log message to record the correct restriction type when removing a page view restriction (Rohit Sharma, Hazh. M. Adam)
* Fix: Avoid potential race condition with new Page subscriptions on the edit view (Alex Tomkins)
* Fix: Use the correct action log when creating a redirect (Thibaud Colas)
* Docs: Document `WAGTAILADMIN_BASE_URL` on "Integrating Wagtail into a Django project" page (Shreshth Srivastava)
* Docs: Replace incorrect screenshot for authors listing on tutorial (Shreshth Srivastava)
* Docs: Add documentation for building non-model-based choosers using the _queryish_ library (Matt Westcott)

Wyświetl plik

@ -93,6 +93,7 @@ This feature was developed by Paarth Agarwal and Thibaud Colas as part of the Go
* Avoid forgotten password link text conflicting with the supplied aria-label (Thibaud Colas)
* Fix log message to record the correct restriction type when removing a page view restriction (Rohit Sharma, Hazh. M. Adam)
* Avoid potential race condition with new Page subscriptions on the edit view (Alex Tomkins)
* Use the correct action log when creating a redirect (Thibaud Colas)
### Documentation

Wyświetl plik

@ -3,6 +3,7 @@ from django.urls import reverse
from wagtail.admin.admin_url_finder import AdminURLFinder
from wagtail.contrib.redirects import models
from wagtail.log_actions import registry as log_registry
from wagtail.models import Page, Site
from wagtail.test.routablepage.models import RoutablePageTest
from wagtail.test.utils import WagtailTestUtils
@ -653,9 +654,14 @@ class TestRedirectsAddView(WagtailTestUtils, TestCase):
# Check that the redirect was created
redirects = models.Redirect.objects.filter(old_path="/test")
redirect = redirects.first()
self.assertEqual(redirects.count(), 1)
self.assertEqual(redirects.first().redirect_link, "http://www.test.com/")
self.assertIsNone(redirects.first().site)
self.assertEqual(redirect.redirect_link, "http://www.test.com/")
self.assertIsNone(redirect.site)
# Check that the action log is marked as "created"
log_entry = log_registry.get_logs_for_instance(redirect).first()
self.assertEqual(log_entry.action, "wagtail.create")
def test_add_with_site(self):
localhost = Site.objects.get(hostname="localhost")

Wyświetl plik

@ -179,7 +179,7 @@ def add(request):
if form.is_valid():
with transaction.atomic():
theredirect = form.save()
log(instance=theredirect, action="wagtail.edit")
log(instance=theredirect, action="wagtail.create")
messages.success(
request,