Include user in log entry when reordering pages

Include `request.user` so `Page.move() can include it in it's log entry.
This will prevent the log entry from having no acting user associated
with it (#6761).
pull/6967/head
Storm Heg 2021-02-03 17:36:28 +01:00
rodzic b213b8cc5a
commit 520fa23ced
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: A13DE630DD3AA5B6
4 zmienionych plików z 9 dodań i 6 usunięć

Wyświetl plik

@ -14,7 +14,7 @@ Changelog
* Utilize `PageQuerySet.defer_streamfields()` to improve efficiency in a few key places (Andy Babic)
* Switch ``register_setting``, ``register_settings_menu_item`` to use SVG icons (Thibaud Colas)
* Add support to SVG icons for ``SearchArea`` subclasses in ``register_admin_search_area`` (Thibaud Colas)
* `get_settings` template tag now supports specifying the variable name with `{% get_settings as var %}` (Samir Shah)
* `get_settings` template tag now supports specifying the variable name with `{% get_settings as var %}` (Samir Shah)
* Fix: StreamField required status is now consistently handled by the `blank` keyword argument (Matt Westcott)
* Fix: Show 'required' asterisks for blocks inside required StreamFields (Matt Westcott)
* Fix: Make image chooser "Select format" fields translatable (Helen Chapman, Thibaud Colas)
@ -23,6 +23,7 @@ Changelog
* Fix: Fix pagination on 'view users in a group' (Sagar Agarwal)
* Fix: Prevent page privacy menu from being triggered by pressing enter on a char field (Sagar Agarwal)
* Fix: Validate host/scheme of return URLs on password authentication forms (Susan Dreher)
* Fix: Reordering a page now includes the correct user in the audit log (Storm Heg)
2.12.3 (05.03.2021)

Wyświetl plik

@ -42,6 +42,7 @@ Bug fixes
* Fix pagination on 'view users in a group' (Sagar Agarwal)
* Prevent page privacy menu from being triggered by pressing enter on a char field (Sagar Agarwal)
* Validate host/scheme of return URLs on password authentication forms (Susan Dreher)
* Reordering a page now includes the correct user in the audit log (Storm Heg)
Upgrade considerations

Wyświetl plik

@ -34,11 +34,11 @@ def set_page_position(request, page_to_move_id):
# right. If left, then left.
old_position = list(parent_page.get_children()).index(page_to_move)
if int(position) < old_position:
page_to_move.move(position_page, pos='left')
page_to_move.move(position_page, pos='left', user=request.user)
elif int(position) > old_position:
page_to_move.move(position_page, pos='right')
page_to_move.move(position_page, pos='right', user=request.user)
else:
# Move page to end
page_to_move.move(parent_page, pos='last-child')
page_to_move.move(parent_page, pos='last-child', user=request.user)
return HttpResponse('')

Wyświetl plik

@ -189,9 +189,10 @@ class TestAuditLog(TestCase):
section = self.root_page.add_child(
instance=SimplePage(title="About us", slug="about", content="hello")
)
user = get_user_model().objects.first()
section.move(self.home_page, user=user)
section.move(self.home_page)
self.assertEqual(PageLogEntry.objects.filter(action='wagtail.move').count(), 1)
self.assertEqual(PageLogEntry.objects.filter(action='wagtail.move', user=user).count(), 1)
def test_page_delete(self):
self.home_page.add_child(