diff --git a/src/wagtail_periodic_review/views.py b/src/wagtail_periodic_review/views.py index 0265b52..f7b6df3 100644 --- a/src/wagtail_periodic_review/views.py +++ b/src/wagtail_periodic_review/views.py @@ -1,18 +1,12 @@ from django.core.exceptions import FieldError from django.utils.translation import gettext as _ -from wagtail import VERSION as WAGTAIL_VERSION from wagtail.admin.views.reports import ReportView +from wagtail.permission_policies.pages import PagePermissionPolicy from .filters import PeriodicReviewFilterSet from .utils import add_review_date_annotations, filter_across_subtypes -if WAGTAIL_VERSION >= (5, 1): - from wagtail.permission_policies.pages import PagePermissionPolicy -else: - from wagtail.models import UserPagePermissionsProxy - - class PeriodicReviewContentReport(ReportView): title = _("Periodic review content") header_icon = "wpr-calendar-stats" @@ -20,11 +14,9 @@ class PeriodicReviewContentReport(ReportView): filterset_class = PeriodicReviewFilterSet def _get_editable_pages(self): - if WAGTAIL_VERSION >= (5, 1): - return PagePermissionPolicy().instances_user_has_permission_for( - self.request.user, "change" - ) - return UserPagePermissionsProxy(self.request.user).editable_pages() + return PagePermissionPolicy().instances_user_has_permission_for( + self.request.user, "change" + ) def get_queryset(self): queryset = filter_across_subtypes( diff --git a/src/wagtail_periodic_review/wagtail_hooks.py b/src/wagtail_periodic_review/wagtail_hooks.py index c0cd26a..5d6448e 100644 --- a/src/wagtail_periodic_review/wagtail_hooks.py +++ b/src/wagtail_periodic_review/wagtail_hooks.py @@ -2,21 +2,15 @@ from django.urls import path, reverse from django.utils.translation import gettext as _ -from wagtail import VERSION as WAGTAIL_VERSION from wagtail import hooks from wagtail.admin.menu import MenuItem from wagtail.admin.ui.components import Component +from wagtail.permission_policies.pages import PagePermissionPolicy from .utils import for_review_this_month, review_overdue from .views import PeriodicReviewContentReport -if WAGTAIL_VERSION >= (5, 1): - from wagtail.permission_policies.pages import PagePermissionPolicy -else: - from wagtail.models import UserPagePermissionsProxy - - class BaseHomePanel(Component): heading = "" description = "" @@ -28,11 +22,9 @@ def __init__(self, request): self.request = request def get_page_list(self): - if WAGTAIL_VERSION >= (5, 1): - return PagePermissionPolicy().instances_user_has_permission_for( - self.request.user, "change" - ) - return UserPagePermissionsProxy(self.request.user).editable_pages() + return PagePermissionPolicy().instances_user_has_permission_for( + self.request.user, "change" + ) def get_context_data(self, parent_context: Mapping[str, Any]) -> Mapping[str, Any]: context = super().get_context_data(parent_context)