Skip to content

Commit

Permalink
Include user in log entry when reordering pages
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
Stormheg committed Mar 31, 2021
1 parent b213b8c commit 520fa23
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions docs/releases/2.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions wagtail/admin/views/pages/ordering.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('')
5 changes: 3 additions & 2 deletions wagtail/core/tests/test_audit_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,10 @@ def test_page_move(self):
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(
Expand Down

0 comments on commit 520fa23

Please sign in to comment.