Skip to content
Snippets Groups Projects
Commit 9f87632a authored by jarmil's avatar jarmil
Browse files

WIP: PDP: FIX: subpage mixin

parent 8f15e9e5
No related branches found
No related tags found
No related merge requests found
......@@ -12,7 +12,7 @@ from wagtail.documents.blocks import DocumentChooserBlock
from wagtail.images.edit_handlers import ImageChooserPanel
from wagtailmetadata.models import MetadataPageMixin
from shared.mixins import MatomoMixin
from shared.mixins import MatomoMixin, SharedSubpageMixin
from tuning import help
from uniweb import models as uniweb
......@@ -85,7 +85,7 @@ class PdpHomePage(
return self
class PdpSubPage(Page, PdpContentMixin, uniweb.SubpageMixin, MetadataPageMixin):
class PdpSubPage(Page, PdpContentMixin, SharedSubpageMixin, MetadataPageMixin):
### FIELDS
### PANELS
......
......@@ -9,3 +9,15 @@ class MatomoMixin(models.Model):
class Meta:
abstract = True
class SharedSubpageMixin:
"""Must be used in class definition before MetadataPageMixin!"""
@property
def root_page(self):
if not hasattr(self, "_root_page"):
# Vypada to hackove ale lze takto pouzit: dle dokumentace get_ancestors vraci stranky v poradi
# od rootu, tedy domovska stranka je druha v poradi
self._root_page = self.get_ancestors().specific()[1]
return self._root_page
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment