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

REF: univerzalni SubpageMixin

parent 33063ba0
No related branches found
No related tags found
2 merge requests!173Release,!134Weby pro MS
......@@ -7,19 +7,16 @@ from wagtail.core.fields import StreamField
from wagtail.core.models import Page
from wagtailmetadata.models import MetadataPageMixin
from shared.models import Article, PersonPage
from shared.models import Article, SharedSubpageMixin
class SubpageMixin:
"""Must be used in class definition before MetadataPageMixin!"""
"""Must be used in class definition before MetadataPageMixin!
Obsolete, misto nej pouzivat SharedSubpageMixin
TODO je pouze v migracich, po odstraneni z nich lze smazat
"""
@property
def root_page(self):
if not hasattr(self, "_root_page"):
self._root_page = (
self.get_ancestors().type(DistrictHomePage).specific().get()
)
return self._root_page
pass
class DistrictHomePage(MetadataPageMixin, Page):
......@@ -133,7 +130,7 @@ class DistrictHomePage(MetadataPageMixin, Page):
return self
class DistrictArticles(SubpageMixin, MetadataPageMixin, Page):
class DistrictArticles(SharedSubpageMixin, MetadataPageMixin, Page):
### FIELDS
max_items = models.IntegerField(
......@@ -162,7 +159,7 @@ class DistrictArticles(SubpageMixin, MetadataPageMixin, Page):
return context
class DistrictContact(SubpageMixin, MetadataPageMixin, Page):
class DistrictContact(SharedSubpageMixin, MetadataPageMixin, Page):
class ContactItemBlock(blocks.StructBlock):
name = blocks.CharBlock(label="Role")
person = blocks.PageChooserBlock(
......
......@@ -9,11 +9,23 @@ from wagtail.images.edit_handlers import ImageChooserPanel
from wagtailmetadata.models import MetadataPageMixin
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
class ArticleTag(TaggedItemBase):
content_object = ParentalKey("shared.Article", on_delete=models.CASCADE)
class Article(MetadataPageMixin, Page):
class Article(SharedSubpageMixin, MetadataPageMixin, Page):
""" Univerzalni clanek pro vsechny weby """
### FIELDS
......@@ -47,7 +59,7 @@ class Article(MetadataPageMixin, Page):
verbose_name = "Článek"
class PersonPage(MetadataPageMixin, Page):
class PersonPage(SharedSubpageMixin, MetadataPageMixin, Page):
""" Stranka Pirata.
Snaha je zadavat tady minimum informaci o osobe a zbytek vytahovat via API z jinych zdroju,
neb nechceme dalsi databazi lidi.
......@@ -114,7 +126,7 @@ class PersonPage(MetadataPageMixin, Page):
return context
class PeoplePage(MetadataPageMixin, Page):
class PeoplePage(SharedSubpageMixin, MetadataPageMixin, Page):
""" Stranka se zobrazenim lidi v dane organizaci
TOOD: subpagemixin
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment