Skip to content

Commit

Permalink
Add HeroAccentColourMixin to ExhibitionPage, and "Exhibition events" …
Browse files Browse the repository at this point in the history
…fields
  • Loading branch information
jamesbiggs committed Dec 2, 2024
1 parent 67129e7 commit 5ed190a
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 5.1.2 on 2024-11-28 16:48
# Generated by Django 5.1.2 on 2024-12-02 15:12
# etna:allowRemoveField
# etna:allowAlterField
# etna:allowDeleteModel
Expand Down Expand Up @@ -97,7 +97,7 @@ class Migration(migrations.Migration):
default="none",
help_text="The accent colour of the page where relevant.",
max_length=20,
verbose_name="hero text colour",
verbose_name="page accent colour",
),
),
migrations.AddField(
Expand Down Expand Up @@ -130,6 +130,44 @@ class Migration(migrations.Migration):
verbose_name="booking details",
),
),
migrations.AddField(
model_name="exhibitionpage",
name="event_links",
field=wagtail.fields.StreamField(
[("event_links", 5)],
block_lookup={
0: (
"wagtail.blocks.CharBlock",
(),
{"label": "Title", "max_length": 100},
),
1: ("wagtail.blocks.CharBlock", (), {"label": "Description"}),
2: ("wagtail.blocks.URLBlock", (), {"label": "URL"}),
3: (
"etna.core.blocks.image.APIImageChooserBlock",
(),
{"label": "Image", "required": False},
),
4: (
"wagtail.blocks.StructBlock",
[[("title", 0), ("description", 1), ("url", 2), ("image", 3)]],
{},
),
5: ("wagtail.blocks.ListBlock", (4,), {"max_num": 2}),
},
null=True,
),
),
migrations.AddField(
model_name="exhibitionpage",
name="event_title",
field=models.CharField(
default="Exhibition events",
help_text="The title of the events section.",
max_length=100,
verbose_name="event title",
),
),
migrations.AddField(
model_name="exhibitionpage",
name="exclude_days",
Expand Down Expand Up @@ -201,6 +239,22 @@ class Migration(migrations.Migration):
to="wagtailcore.page",
),
),
migrations.AddField(
model_name="exhibitionpage",
name="hero_accent_colour",
field=models.CharField(
choices=[
("none", "None"),
("contrast", "Contrast"),
("tint", "Tint"),
("accent", "Accent"),
],
default="none",
help_text="The accent colour of the hero component.",
max_length=20,
verbose_name="hero component colour",
),
),
migrations.AddField(
model_name="exhibitionpage",
name="hero_image_caption",
Expand Down Expand Up @@ -407,7 +461,7 @@ class Migration(migrations.Migration):
4: (
"etna.core.blocks.image.APIImageChooserBlock",
(),
{"label": "Background image", "required": False},
{"label": "Background image"},
),
5: (
"wagtail.blocks.StructBlock",
Expand Down
25 changes: 22 additions & 3 deletions etna/whatson/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from etna.articles.models import ArticleTagMixin
from etna.collections.models import TopicalPageMixin
from etna.core.blocks import (
FeaturedExternalLinkBlock,
FeaturedPagesBlock,
ImageGalleryBlock,
LargeCardLinksBlock,
Expand All @@ -36,6 +37,7 @@
from etna.core.models import (
AccentColourMixin,
BasePageWithRequiredIntro,
HeroAccentColourMixin,
RequiredHeroImageMixin,
)
from etna.core.serializers import DefaultPageSerializer, RichTextSerializer
Expand Down Expand Up @@ -755,6 +757,7 @@ def save(self, *args, **kwargs):
class ExhibitionPage(
ArticleTagMixin,
AccentColourMixin,
HeroAccentColourMixin,
RequiredHeroImageMixin,
TopicalPageMixin,
BasePageWithRequiredIntro,
Expand Down Expand Up @@ -891,6 +894,19 @@ class ExhibitionPage(

related_pages = StreamField(FeaturedPagesBlock(), blank=True, null=True)

event_title = models.CharField(
max_length=100,
verbose_name=_("event title"),
help_text=_("The title of the events section."),
default="Exhibition events",
)

event_links = StreamField(
[("event_links", blocks.ListBlock(FeaturedExternalLinkBlock(), max_num=2))],
max_num=1,
null=True,
)

shop = StreamField(
[("shop", ShopCollectionBlock())],
blank=True,
Expand All @@ -912,9 +928,6 @@ def type_label(cls) -> str:
"""
Overrides the type_label method from BasePage, to return the correct
type label for the exhibition page.
NOTE: Removed `@classmethod` as that only acts on the class itself rather
than an instance of the class.
"""
if cls.end_date < timezone.now().date():
return "Past exhibition"
Expand All @@ -930,6 +943,7 @@ class Meta:
[
FieldPanel("hero_image"),
FieldPanel("hero_image_caption"),
FieldPanel("hero_accent_colour"),
FieldPanel("subtitle"),
FieldPanel("accent_colour"),
],
Expand All @@ -950,6 +964,8 @@ class Meta:
FieldPanel("related_pages_title"),
FieldPanel("featured_page"),
FieldPanel("related_pages"),
FieldPanel("event_title"),
FieldPanel("event_links"),
FieldPanel("shop"),
],
heading=_("Related content"),
Expand Down Expand Up @@ -1007,6 +1023,7 @@ class Meta:
api_fields = (
BasePageWithRequiredIntro.api_fields
+ RequiredHeroImageMixin.api_fields
+ HeroAccentColourMixin.api_fields
+ AccentColourMixin.api_fields
+ [
APIField("subtitle"),
Expand All @@ -1029,6 +1046,8 @@ class Meta:
APIField("related_pages_title"),
APIField("featured_page", serializer=DefaultPageSerializer()),
APIField("related_pages"),
APIField("event_title"),
APIField("event_links"),
APIField("shop"),
APIField("plan_your_visit"),
]
Expand Down

0 comments on commit 5ed190a

Please sign in to comment.