Fix incorrect logging of move VS reorder

pull/7776/head
Andy Babic 2021-12-12 10:31:55 +00:00 zatwierdzone przez Andy Babic
rodzic e602990e39
commit 0086c7ba7a
2 zmienionych plików z 5 dodań i 2 usunięć
wagtail/core

Wyświetl plik

@ -1546,7 +1546,7 @@ class Page(AbstractPage, index.Indexed, ClusterableModel, metaclass=PageBase):
log_entry = log(
instance=self,
# Check if page was reordered (reordering doesn't change the parent)
action='wagtail.move' if url_path_changed else 'wagtail.reorder',
action='wagtail.move' if parent_before.id != parent_after.id else 'wagtail.reorder',
user=user,
data={
'source': {

Wyświetl plik

@ -209,7 +209,10 @@ class TestAuditLog(TestCase):
instance=SimplePage(title="About us", slug="about", content="hello")
)
user = get_user_model().objects.first()
section.move(self.home_page, user=user)
# move() interprets `target` as an intended 'sibling' by default, so
# we must use `pos` to indicate that `self.home_page` should be the
# new 'parent'
section.move(self.home_page, pos="last-child", user=user)
self.assertEqual(PageLogEntry.objects.filter(action='wagtail.move', user=user).count(), 1)
self.assertEqual(PageLogEntry.objects.filter(action='wagtail.reorder', user=user).count(), 0)