Remove UserPagePermissionsProxy from action_menu and wagtailadmin_tags

pull/11138/head
Matt Westcott 2023-10-27 15:43:31 +01:00
rodzic 6238f899b6
commit 55a48a212c
3 zmienionych plików z 0 dodań i 21 usunięć

Wyświetl plik

@ -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

Wyświetl plik

@ -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

Wyświetl plik

@ -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)