Fix resolving parent pages

The order is actually correct for what we want. Also update the type
This commit is contained in:
Jake Howard 2022-07-16 10:29:47 +01:00
parent 690095ea52
commit 3306ec4e5a
Signed by: jake
GPG key ID: 57AFB45680EDD477

View file

@ -8,7 +8,7 @@ from wagtail.admin.panels import FieldPanel
from wagtail.fields import StreamField from wagtail.fields import StreamField
from wagtail.images import get_image_model_string from wagtail.images import get_image_model_string
from wagtail.images.views.serve import generate_image_url from wagtail.images.views.serve import generate_image_url
from wagtail.models import Page from wagtail.models import Page, PageQuerySet
from wagtail.snippets.models import register_snippet from wagtail.snippets.models import register_snippet
from website.common.utils import count_words from website.common.utils import count_words
@ -28,11 +28,11 @@ class BasePage(Page):
def body_class(cls) -> str: def body_class(cls) -> str:
return "page-" + cls._meta.db_table.replace("_", "-") return "page-" + cls._meta.db_table.replace("_", "-")
def get_parent_pages(self) -> models.QuerySet[Page]: def get_parent_pages(self) -> PageQuerySet:
""" """
Shim over the fact everything is in 1 tree Shim over the fact everything is in 1 tree
""" """
return self.get_ancestors().reverse().exclude(depth__lte=2) return self.get_ancestors().exclude(depth__lte=2)
class BaseContentMixin(models.Model): class BaseContentMixin(models.Model):