Make PageListingMixin.annotate_queryset public and use page_permission_policy directly

pull/12324/head
Sage Abdullah 2024-09-16 10:29:24 +01:00 zatwierdzone przez Matt Westcott
rodzic d8bdc900c8
commit e46f6920b6
4 zmienionych plików z 7 dodań i 7 usunięć

Wyświetl plik

@ -206,9 +206,9 @@ class PageListingMixin:
return ordering
def _annotate_queryset(self, pages):
def annotate_queryset(self, pages):
pages = pages.prefetch_related("content_type", "sites_rooted_here").filter(
pk__in=self.permission_policy.explorable_instances(
pk__in=page_permission_policy.explorable_instances(
self.request.user
).values_list("pk", flat=True)
)
@ -292,7 +292,7 @@ class IndexView(PageListingMixin, generic.IndexView):
def get_base_queryset(self):
pages = self.model.objects.filter(depth__gt=1)
pages = self._annotate_queryset(pages)
pages = self.annotate_queryset(pages)
return pages
@ -365,7 +365,7 @@ class ExplorableIndexView(IndexView):
else:
pages = self.parent_page.get_children()
pages = self._annotate_queryset(pages)
pages = self.annotate_queryset(pages)
return pages
def search_queryset(self, queryset):

Wyświetl plik

@ -104,7 +104,7 @@ class SearchView(PageListingMixin, PermissionCheckedMixin, BaseListingView):
if self.selected_content_type:
pages = pages.filter(content_type=self.selected_content_type)
pages = self._annotate_queryset(pages)
pages = self.annotate_queryset(pages)
# Parse query and filter
pages, self.all_pages = page_filter_search(

Wyświetl plik

@ -56,7 +56,7 @@ class ContentTypeUseView(PageListingMixin, PermissionCheckedMixin, BaseListingVi
def get_base_queryset(self):
queryset = self.page_class.objects.all().specific(defer=True)
return self._annotate_queryset(queryset)
return self.annotate_queryset(queryset)
def get_index_url(self):
return reverse(

Wyświetl plik

@ -451,7 +451,7 @@ class WorkflowUsageView(PageListingMixin, PermissionCheckedMixin, BaseListingVie
self.request.user, "change"
).filter(depth__gt=1)
pages = self.object.all_pages() & editable_pages
pages = self._annotate_queryset(pages)
pages = self.annotate_queryset(pages)
return pages