Skip to content

Commit

Permalink
DSRC-87: Hub Page fields (#1682)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrew Hosgood <[email protected]>
  • Loading branch information
jamesbiggs and ahosgood authored Jul 22, 2024
1 parent 3ae3aeb commit f9d3dbf
Show file tree
Hide file tree
Showing 7 changed files with 323 additions and 70 deletions.
44 changes: 22 additions & 22 deletions etna/articles/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from etna.collections.models import TopicalPageMixin
from etna.core.blocks import AuthorPromotedPagesBlock, FeaturedCollectionBlock
from etna.core.models import (
BasePageWithIntro,
BasePageWithRequiredIntro,
ContentWarningMixin,
HeroImageMixin,
NewLabelMixin,
Expand Down Expand Up @@ -118,7 +118,7 @@ class Meta:
api_fields = [APIField("tags", serializer=TaggableSerializer())]


class ArticleIndexPage(BasePageWithIntro):
class ArticleIndexPage(BasePageWithRequiredIntro):
"""ArticleIndexPage
This page lists the ArticlePage objects that are children of this page.
Expand All @@ -142,7 +142,7 @@ class ArticleIndexPage(BasePageWithIntro):
null=True,
)

api_fields = BasePageWithIntro.api_fields + [
api_fields = BasePageWithRequiredIntro.api_fields + [
APIField(
"featured_article",
serializer=DefaultPageSerializer(required_api_fields=["teaser_image"]),
Expand Down Expand Up @@ -179,7 +179,7 @@ def article_pages(self):
.specific()
)

content_panels = BasePageWithIntro.content_panels + [
content_panels = BasePageWithRequiredIntro.content_panels + [
PageChooserPanel(
"featured_article",
[
Expand All @@ -205,7 +205,7 @@ class ArticlePage(
ContentWarningMixin,
NewLabelMixin,
ArticleTagMixin,
BasePageWithIntro,
BasePageWithRequiredIntro,
):
"""ArticlePage
Expand All @@ -225,7 +225,7 @@ class Meta:
verbose_name_public = _("the story of")

content_panels = (
BasePageWithIntro.content_panels
BasePageWithRequiredIntro.content_panels
+ RequiredHeroImageMixin.content_panels
+ [
MultiFieldPanel(
Expand All @@ -242,7 +242,7 @@ class Meta:

promote_panels = (
NewLabelMixin.promote_panels
+ BasePageWithIntro.promote_panels
+ BasePageWithRequiredIntro.promote_panels
+ ArticleTagMixin.promote_panels
+ [
TopicalPageMixin.get_topics_inlinepanel(),
Expand All @@ -254,7 +254,7 @@ class Meta:
subpage_types = []

search_fields = (
BasePageWithIntro.search_fields
BasePageWithRequiredIntro.search_fields
+ ArticleTagMixin.search_fields
+ [
index.SearchField("body"),
Expand All @@ -263,12 +263,12 @@ class Meta:
]
)

default_api_fields = BasePageWithIntro.default_api_fields + [
default_api_fields = BasePageWithRequiredIntro.default_api_fields + [
APIField("is_newly_published"),
]

api_fields = (
BasePageWithIntro.api_fields
BasePageWithRequiredIntro.api_fields
+ RequiredHeroImageMixin.api_fields
+ ContentWarningMixin.api_fields
+ NewLabelMixin.api_fields
Expand Down Expand Up @@ -375,7 +375,7 @@ class FocusedArticlePage(
ContentWarningMixin,
NewLabelMixin,
ArticleTagMixin,
BasePageWithIntro,
BasePageWithRequiredIntro,
):
"""FocusedArticlePage
Expand All @@ -395,7 +395,7 @@ class Meta:
verbose_name_public = _("focus on")

content_panels = (
BasePageWithIntro.content_panels
BasePageWithRequiredIntro.content_panels
+ HeroImageMixin.content_panels
+ [
MultiFieldPanel(
Expand All @@ -412,7 +412,7 @@ class Meta:

promote_panels = (
NewLabelMixin.promote_panels
+ BasePageWithIntro.promote_panels
+ BasePageWithRequiredIntro.promote_panels
+ ArticleTagMixin.promote_panels
+ [
AuthorPageMixin.get_authors_inlinepanel(),
Expand All @@ -425,7 +425,7 @@ class Meta:
subpage_types = []

search_fields = (
BasePageWithIntro.search_fields
BasePageWithRequiredIntro.search_fields
+ ArticleTagMixin.search_fields
+ [
index.SearchField("body"),
Expand All @@ -435,12 +435,12 @@ class Meta:
]
)

default_api_fields = BasePageWithIntro.default_api_fields + [
default_api_fields = BasePageWithRequiredIntro.default_api_fields + [
APIField("is_newly_published"),
]

api_fields = (
BasePageWithIntro.api_fields
BasePageWithRequiredIntro.api_fields
+ HeroImageMixin.api_fields
+ ContentWarningMixin.api_fields
+ NewLabelMixin.api_fields
Expand Down Expand Up @@ -589,7 +589,7 @@ class RecordArticlePage(
ContentWarningMixin,
NewLabelMixin,
ArticleTagMixin,
BasePageWithIntro,
BasePageWithRequiredIntro,
):
template = "articles/record_article_page.html"
parent_page_types = ["articles.ArticleIndexPage"]
Expand Down Expand Up @@ -674,7 +674,7 @@ class Meta:
verbose_name_plural = _("record articles")
verbose_name_public = _("record revealed")

content_panels = BasePageWithIntro.content_panels + [
content_panels = BasePageWithRequiredIntro.content_panels + [
FieldPanel("intro_image"),
MultiFieldPanel(
heading="Content Warning Options",
Expand Down Expand Up @@ -722,7 +722,7 @@ class Meta:

promote_panels = (
NewLabelMixin.promote_panels
+ BasePageWithIntro.promote_panels
+ BasePageWithRequiredIntro.promote_panels
+ ArticleTagMixin.promote_panels
+ [
TopicalPageMixin.get_topics_inlinepanel(),
Expand All @@ -731,7 +731,7 @@ class Meta:
)

search_fields = (
BasePageWithIntro.search_fields
BasePageWithRequiredIntro.search_fields
+ ArticleTagMixin.search_fields
+ [
index.SearchField("gallery_text"),
Expand All @@ -742,12 +742,12 @@ class Meta:
]
)

default_api_fields = BasePageWithIntro.default_api_fields + [
default_api_fields = BasePageWithRequiredIntro.default_api_fields + [
APIField("is_newly_published"),
]

api_fields = (
BasePageWithIntro.api_fields
BasePageWithRequiredIntro.api_fields
+ ContentWarningMixin.api_fields
+ NewLabelMixin.api_fields
+ ArticleTagMixin.api_fields
Expand Down
50 changes: 28 additions & 22 deletions etna/collections/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from ..alerts.models import AlertMixin
from ..core.models import (
BasePage,
BasePageWithIntro,
BasePageWithRequiredIntro,
ContentWarningMixin,
RequiredHeroImageMixin,
)
Expand Down Expand Up @@ -83,7 +83,7 @@ def clean(self) -> None:
return super().clean()


class ExplorerIndexPage(AlertMixin, BasePageWithIntro):
class ExplorerIndexPage(AlertMixin, BasePageWithRequiredIntro):
"""Collection Explorer landing BasePage.
This page is the starting point for a user's journey through the collection
Expand Down Expand Up @@ -123,7 +123,7 @@ class ExplorerIndexPage(AlertMixin, BasePageWithIntro):
null=True,
)

content_panels = BasePageWithIntro.content_panels + [
content_panels = BasePageWithRequiredIntro.content_panels + [
FieldPanel("body"),
MultiFieldPanel(
[
Expand All @@ -143,7 +143,9 @@ class ExplorerIndexPage(AlertMixin, BasePageWithIntro):
),
]

settings_panels = BasePageWithIntro.settings_panels + AlertMixin.settings_panels
settings_panels = (
BasePageWithRequiredIntro.settings_panels + AlertMixin.settings_panels
)

parent_page_types = ["home.HomePage"]
subpage_types = [
Expand All @@ -157,7 +159,7 @@ class ExplorerIndexPage(AlertMixin, BasePageWithIntro):

api_fields = (
AlertMixin.api_fields
+ BasePageWithIntro.api_fields
+ BasePageWithRequiredIntro.api_fields
+ [
APIField("body"),
APIField("articles_title"),
Expand All @@ -171,7 +173,7 @@ class ExplorerIndexPage(AlertMixin, BasePageWithIntro):
)


class TopicExplorerIndexPage(RequiredHeroImageMixin, BasePageWithIntro):
class TopicExplorerIndexPage(RequiredHeroImageMixin, BasePageWithRequiredIntro):
"""Topic explorer BasePage.
This page lists all child TopicExplorerPages
Expand All @@ -180,7 +182,7 @@ class TopicExplorerIndexPage(RequiredHeroImageMixin, BasePageWithIntro):
body = StreamField(TopicIndexPageStreamBlock, blank=True)

content_panels = (
BasePageWithIntro.content_panels
BasePageWithRequiredIntro.content_panels
+ RequiredHeroImageMixin.content_panels
+ [
FieldPanel("body"),
Expand All @@ -192,7 +194,7 @@ class TopicExplorerIndexPage(RequiredHeroImageMixin, BasePageWithIntro):

api_fields = (
RequiredHeroImageMixin.api_fields
+ BasePageWithIntro.api_fields
+ BasePageWithRequiredIntro.api_fields
+ [
APIField("body"),
APIField(
Expand Down Expand Up @@ -233,7 +235,7 @@ def explorer_pages(self):
]


class TopicExplorerPage(RequiredHeroImageMixin, AlertMixin, BasePageWithIntro):
class TopicExplorerPage(RequiredHeroImageMixin, AlertMixin, BasePageWithRequiredIntro):
"""Topic explorer page.
This page represents one of the many categories a user may select in the
Expand Down Expand Up @@ -272,7 +274,7 @@ class Meta:
)

content_panels = (
BasePageWithIntro.content_panels
BasePageWithRequiredIntro.content_panels
+ RequiredHeroImageMixin.content_panels
+ [
PageChooserPanel(
Expand Down Expand Up @@ -306,7 +308,7 @@ class Meta:
api_fields = (
RequiredHeroImageMixin.api_fields
+ AlertMixin.api_fields
+ BasePageWithIntro.api_fields
+ BasePageWithRequiredIntro.api_fields
+ [
APIField("body"),
APIField(
Expand Down Expand Up @@ -412,7 +414,7 @@ def related_page_pks(self) -> Tuple[int]:
)


class TimePeriodExplorerIndexPage(RequiredHeroImageMixin, BasePageWithIntro):
class TimePeriodExplorerIndexPage(RequiredHeroImageMixin, BasePageWithRequiredIntro):
"""Time period explorer BasePage.
This page lists all child TimePeriodExplorerPage
Expand All @@ -421,7 +423,7 @@ class TimePeriodExplorerIndexPage(RequiredHeroImageMixin, BasePageWithIntro):
body = StreamField(TopicIndexPageStreamBlock, blank=True)

content_panels = (
BasePageWithIntro.content_panels
BasePageWithRequiredIntro.content_panels
+ RequiredHeroImageMixin.content_panels
+ [
FieldPanel("body"),
Expand Down Expand Up @@ -460,7 +462,7 @@ def explorer_pages(self):
]
api_fields = (
RequiredHeroImageMixin.api_fields
+ BasePageWithIntro.api_fields
+ BasePageWithRequiredIntro.api_fields
+ [
APIField("body"),
APIField(
Expand All @@ -473,7 +475,9 @@ def explorer_pages(self):
)


class TimePeriodExplorerPage(RequiredHeroImageMixin, AlertMixin, BasePageWithIntro):
class TimePeriodExplorerPage(
RequiredHeroImageMixin, AlertMixin, BasePageWithRequiredIntro
):
"""Time period BasePage.
This page represents one of the many categories a user may select in the
Expand Down Expand Up @@ -504,7 +508,7 @@ class Meta:
start_year = models.IntegerField(blank=False)
end_year = models.IntegerField(blank=False)
content_panels = (
BasePageWithIntro.content_panels
BasePageWithRequiredIntro.content_panels
+ RequiredHeroImageMixin.content_panels
+ [
PageChooserPanel(
Expand All @@ -524,7 +528,7 @@ class Meta:
api_fields = (
RequiredHeroImageMixin.api_fields
+ AlertMixin.api_fields
+ BasePageWithIntro.api_fields
+ BasePageWithRequiredIntro.api_fields
+ [
APIField("body"),
APIField(
Expand Down Expand Up @@ -802,7 +806,9 @@ def to_representation(self, value):
}


class HighlightGalleryPage(TopicalPageMixin, ContentWarningMixin, BasePageWithIntro):
class HighlightGalleryPage(
TopicalPageMixin, ContentWarningMixin, BasePageWithRequiredIntro
):
parent_page_types = [TimePeriodExplorerPage, TopicExplorerPage]
subpage_types = []

Expand All @@ -819,7 +825,7 @@ class HighlightGalleryPage(TopicalPageMixin, ContentWarningMixin, BasePageWithIn
)

api_fields = (
BasePageWithIntro.api_fields
BasePageWithRequiredIntro.api_fields
+ ContentWarningMixin.api_fields
+ [
APIField(
Expand All @@ -837,7 +843,7 @@ class Meta:
verbose_name_plural = _("highlight gallery pages")
verbose_name_public = _("in pictures")

content_panels = BasePageWithIntro.content_panels + [
content_panels = BasePageWithRequiredIntro.content_panels + [
MultiFieldPanel(
heading="Content Warning Options",
classname="collapsible",
Expand All @@ -862,11 +868,11 @@ class Meta:
),
]

default_api_fields = BasePageWithIntro.default_api_fields + [
default_api_fields = BasePageWithRequiredIntro.default_api_fields + [
APIField("highlight_image_count"),
]

promote_panels = BasePageWithIntro.promote_panels + [
promote_panels = BasePageWithRequiredIntro.promote_panels + [
TopicalPageMixin.get_topics_inlinepanel(),
TopicalPageMixin.get_time_periods_inlinepanel(),
]
Expand Down
Loading

0 comments on commit f9d3dbf

Please sign in to comment.