ImportError: cannot import name 'UserPagePermissionsProxy' from 'wagtail.models'
and here how it is explained to be fixed:
The wagtail.models.UserPagePermissionsProxy class and get_pages_with_direct_explore_permission, get_explorable_root_page and users_with_page_permission functions have been removed; equivalent functionality exists in the wagtail.permission_policies.pages.PagePermissionPolicy class.
here how it should be the code:
from wagtail.permission_policies.pages import PagePermissionPolicy
@classmethod
def get_pages_with_reviews_for_user(cls, user):
"""
Return a queryset of pages which have reviews, for which the user has edit permission
"""
permission_policy = PagePermissionPolicy()
reviewed_pages = cls.objects.order_by("-created_at").values_list(
revision_page_fk_relation, "created_at"
)
# Annotate datetime when a review was last created for this page
last_review_requested_at = Case(
*[When(pk=pk, then=Value(created_at)) for pk, created_at in reviewed_pages],
output_field=models.DateTimeField(),
)
return (
permission_policy.instances_user_has_permission_for(user, "change")
.filter(pk__in=(page[0] for page in reviewed_pages))
.annotate(last_review_requested_at=last_review_requested_at)
.order_by("-last_review_requested_at")
)
this is the error that is appearing:
and here how it is explained to be fixed: The wagtail.models.UserPagePermissionsProxy class and get_pages_with_direct_explore_permission, get_explorable_root_page and users_with_page_permission functions have been removed; equivalent functionality exists in the wagtail.permission_policies.pages.PagePermissionPolicy class.
here how it should be the code: