7

Move comment to top of function

This commit is contained in:
Jasper Berghoef
2018-05-31 11:02:39 +02:00
parent d94890848d
commit 7010f5acea

View File

@ -170,18 +170,17 @@ def page_listing_more_buttons(page, page_perms, is_parent=False):
class CorrectedPagesSummaryItem(PagesSummaryItem):
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.
# 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)
if root_page:
pages = utils.exclude_variants(
Page.objects.descendant_of(root_page, inclusive=True))
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():
page_count -= 1