kopia lustrzana https://github.com/wagtail/wagtail
Optimization of UserPagePermissionsProxy.revisions_for_moderation (#5311)
revisions_for_moderation() was iterating over Page instances only to use their path attribute. The optimization uses values_list() over the GroupPagePermission queryset to retrieve only the page paths without having to create the model instances in memory. This saves roughly 50% of the runtime.pull/5403/head
rodzic
4a1f26778f
commit
41f80af5db
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -378,6 +378,7 @@ Contributors
|
|||
* George Hickman
|
||||
* Eric Dyken
|
||||
* Jordan Bauer
|
||||
* Fidel Ramos
|
||||
|
||||
Translators
|
||||
===========
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue