0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-12-01 11:41:20 +01:00

Refactor user_has_any_page_permission to use PagePermissionPolicy

This commit is contained in:
Sage Abdullah 2023-06-08 13:05:40 +01:00
parent b03296bbe4
commit 38368f0f9d
No known key found for this signature in database
GPG Key ID: EB1A33CC51CC0217

View File

@ -15,6 +15,7 @@ from django.utils.translation import override
from wagtail.admin import messages
from wagtail.log_actions import LogContext
from wagtail.models import GroupPagePermission
from wagtail.permission_policies.pages import PagePermissionPolicy
def users_with_page_permission(page, permission_type, include_superusers=True):
@ -137,7 +138,7 @@ def user_has_any_page_permission(user):
# At least one of the users groups has a GroupPagePermission.
# The user can probably do something.
if GroupPagePermission.objects.filter(group__in=user.groups.all()).exists():
if bool(PagePermissionPolicy().get_cached_permissions_for_user(user)):
return True
# Specific permissions for a page type do not mean anything.