Move comment to top of function
This commit is contained in:
@ -170,18 +170,17 @@ def page_listing_more_buttons(page, page_perms, is_parent=False):
|
|||||||
|
|
||||||
class CorrectedPagesSummaryItem(PagesSummaryItem):
|
class CorrectedPagesSummaryItem(PagesSummaryItem):
|
||||||
def get_context(self):
|
def get_context(self):
|
||||||
context = super().get_context()
|
# Perform the same check as Wagtail to get the correct count.
|
||||||
|
|
||||||
# Only correct the count when a root page is available to the user.
|
# Only correct the count when a root page is available to the user.
|
||||||
# The `PagesSummaryItem` will return a page count of 0 otherwise.
|
# The `PagesSummaryItem` will return a page count of 0 otherwise.
|
||||||
|
# https://github.com/wagtail/wagtail/blob/5c9ff23e229acabad406c42c4e13cbaea32e6c15/wagtail/admin/site_summary.py#L38
|
||||||
|
context = super().get_context()
|
||||||
root_page = context.get('root_page', None)
|
root_page = context.get('root_page', None)
|
||||||
if root_page:
|
if root_page:
|
||||||
pages = utils.exclude_variants(
|
pages = utils.exclude_variants(
|
||||||
Page.objects.descendant_of(root_page, inclusive=True))
|
Page.objects.descendant_of(root_page, inclusive=True))
|
||||||
page_count = pages.count()
|
page_count = pages.count()
|
||||||
|
|
||||||
# Perform the same check as Wagtail to get the correct count.
|
|
||||||
# https://github.com/wagtail/wagtail/blob/5c9ff23e229acabad406c42c4e13cbaea32e6c15/wagtail/admin/site_summary.py#L38
|
|
||||||
if root_page.is_root():
|
if root_page.is_root():
|
||||||
page_count -= 1
|
page_count -= 1
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user