diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 6e31af286..87033e081 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -25,6 +25,7 @@ Changelog * Added support for custom search handler classes to modeladmin's IndexView, and added a class that uses the default Wagtail search backend for searching (Seb Brown, Andy Babic) * Improved heading structure for screen reader users navigating the CMS admin (Beth Menzies, Helen Chapman) * Updated group edit view to expose the Permission object for each checkbox (George Hickman) + * Improve performance of Pages for Moderation panel (Fidel Ramos) * Fix: ModelAdmin no longer fails when filtering over a foreign key relation (Jason Dilworth, Matt Westcott) * Fix: The Wagtail version number is now visible within the Settings menu (Kevin Howbrook) * Fix: Scaling images now rounds values to an integer so that images render without errors (Adrian Brunyate) diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index badf7a942..a6fe94b24 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -378,6 +378,7 @@ Contributors * George Hickman * Eric Dyken * Jordan Bauer +* Fidel Ramos Translators =========== diff --git a/docs/releases/2.6.rst b/docs/releases/2.6.rst index 3033483b5..fb24f1072 100644 --- a/docs/releases/2.6.rst +++ b/docs/releases/2.6.rst @@ -34,6 +34,7 @@ Other features * Added support for custom search handler classes to modeladmin's IndexView, and added a class that uses the default Wagtail search backend for searching (Seb Brown, Andy Babic) * Improved heading structure for screen reader users navigating the CMS admin (Beth Menzies, Helen Chapman) * Update group edit view to expose the ``Permission`` object for each checkbox (George Hickman) + * Improve performance of Pages for Moderation panel (Fidel Ramos) Bug fixes diff --git a/wagtail/core/models.py b/wagtail/core/models.py index 95933c065..a6fbf3bbe 100644 --- a/wagtail/core/models.py +++ b/wagtail/core/models.py @@ -1623,15 +1623,17 @@ class UserPagePermissionsProxy: # get the list of pages for which they have direct publish permission # (i.e. they can publish any page within this subtree) - publishable_pages = [perm.page for perm in self.permissions if perm.permission_type == 'publish'] - if not publishable_pages: + publishable_pages_paths = self.permissions.filter( + permission_type='publish' + ).values_list('page__path', flat=True).distinct() + if not publishable_pages_paths: return PageRevision.objects.none() # compile a filter expression to apply to the PageRevision.submitted_revisions manager: # return only those pages whose paths start with one of the publishable_pages paths - only_my_sections = Q(page__path__startswith=publishable_pages[0].path) - for page in publishable_pages[1:]: - only_my_sections = only_my_sections | Q(page__path__startswith=page.path) + only_my_sections = Q(page__path__startswith=publishable_pages_paths[0]) + for page_path in publishable_pages_paths[1:]: + only_my_sections = only_my_sections | Q(page__path__startswith=page_path) # return the filtered queryset return PageRevision.submitted_revisions.filter(only_my_sections)