From 55a48a212c89304d4f016c73770527837f70c85c Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Fri, 27 Oct 2023 15:43:31 +0100 Subject: [PATCH] Remove UserPagePermissionsProxy from action_menu and wagtailadmin_tags --- docs/reference/hooks.md | 1 - wagtail/admin/action_menu.py | 4 ---- wagtail/admin/templatetags/wagtailadmin_tags.py | 16 ---------------- 3 files changed, 21 deletions(-) diff --git a/docs/reference/hooks.md b/docs/reference/hooks.md index 1c83f72ace..38e5bcf269 100644 --- a/docs/reference/hooks.md +++ b/docs/reference/hooks.md @@ -814,7 +814,6 @@ The `get_url`, `is_shown`, `get_context_data` and `render_html` methods all acce - `page` - for `view` = `'edit'` or `'revisions_revert'`, the page being edited - `parent_page` - for `view` = `'create'`, the parent page of the page being created - `request` - the current request object -- `user_page_permissions` - a `UserPagePermissionsProxy` object for the current user, to test permissions against (deprecated) ```python from wagtail import hooks diff --git a/wagtail/admin/action_menu.py b/wagtail/admin/action_menu.py index 372603368f..dedfe61630 100644 --- a/wagtail/admin/action_menu.py +++ b/wagtail/admin/action_menu.py @@ -10,7 +10,6 @@ from django.utils.translation import gettext_lazy as _ from wagtail import hooks from wagtail.admin.ui.components import Component -from wagtail.models import UserPagePermissionsProxy from wagtail.utils.deprecation import RemovedInWagtail60Warning @@ -44,7 +43,6 @@ class ActionMenuItem(Component): 'view' = 'create', 'edit' or 'revisions_revert' 'page' (if view = 'edit' or 'revisions_revert') = the page being edited 'parent_page' (if view = 'create') = the parent page of the page being created - 'user_page_permissions' = a UserPagePermissionsProxy for the current user, to test permissions against 'lock' = a Lock object if the page is locked, otherwise None 'locked_for_user' = True if the lock prevents the current user from editing the page may also contain: @@ -291,8 +289,6 @@ class PageActionMenu: self.context = kwargs self.context["request"] = request page = self.context.get("page") - user_page_permissions = UserPagePermissionsProxy(self.request.user) - self.context["user_page_permissions"] = user_page_permissions if page: self.context["user_page_permissions_tester"] = page.permissions_for_user( self.request.user diff --git a/wagtail/admin/templatetags/wagtailadmin_tags.py b/wagtail/admin/templatetags/wagtailadmin_tags.py index 5a9555858e..c5724716bf 100644 --- a/wagtail/admin/templatetags/wagtailadmin_tags.py +++ b/wagtail/admin/templatetags/wagtailadmin_tags.py @@ -53,7 +53,6 @@ from wagtail.models import ( Locale, Page, PageViewRestriction, - UserPagePermissionsProxy, ) from wagtail.permission_policies.pages import PagePermissionPolicy from wagtail.telepath import JSContext @@ -149,18 +148,6 @@ def widgettype(bound_field): return "" -def _get_user_page_permissions(context): - # RemovedInWagtail60Warning: Remove this function - - # Create a UserPagePermissionsProxy object to represent the user's global permissions, and - # cache it in the context for the duration of the page request, if one does not exist already - if "user_page_permissions" not in context: - context["user_page_permissions"] = UserPagePermissionsProxy( - context["request"].user - ) - return context["user_page_permissions"] - - @register.simple_tag(takes_context=True) def page_permissions(context, page): """ @@ -168,9 +155,6 @@ def page_permissions(context, page): Sets the variable 'page_perms' to a PagePermissionTester object that can be queried to find out what actions the current logged-in user can perform on the given page. """ - # RemovedInWagtail60Warning: Keep the UserPagePermissionsProxy object in the context - # for backwards compatibility during the deprecation period, even though we don't use it - _get_user_page_permissions(context) return page.permissions_for_user(context["request"].user)