Skip to content

Commit

Permalink
Move subtitle below title, make attribution required, and description…
Browse files Browse the repository at this point in the history
… -> body(streamfield)
  • Loading branch information
jamesbiggs committed Dec 5, 2024
1 parent a18c179 commit 8aab118
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 14 deletions.
1 change: 1 addition & 0 deletions etna/core/blocks/quote.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class ReviewBlock(QuoteBlock):
a newspaper, that has given us a review. A quote block with stars.
"""

attribution = blocks.CharBlock(required=True, max_length=100)
stars = blocks.ChoiceBlock(
choices=[
(0, "No stars"),
Expand Down
7 changes: 6 additions & 1 deletion etna/whatson/blocks.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from wagtail import blocks

from etna.core.blocks import PageListBlock
from etna.core.blocks import PageListBlock, ParagraphBlock, QuoteBlock


class WhatsOnPromotedLinksBlock(blocks.StructBlock):
Expand All @@ -10,3 +10,8 @@ class WhatsOnPromotedLinksBlock(blocks.StructBlock):
class Meta:
template = "blocks/whats_on_promoted_links.html"
icon = "list"


class ExhibitionPageStreamBlock(blocks.StreamBlock):
paragraph = ParagraphBlock()
quote = QuoteBlock()
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 5.1.2 on 2024-12-04 10:01
# Generated by Django 5.1.2 on 2024-12-05 10:56
# etna:allowRemoveField
# etna:allowAlterField
# etna:allowDeleteModel
Expand Down Expand Up @@ -29,6 +29,10 @@ class Migration(migrations.Migration):
model_name="exhibitionpage",
name="articles_title",
),
migrations.RemoveField(
model_name="exhibitionpage",
name="description",
),
migrations.RemoveField(
model_name="exhibitionpage",
name="dwell_time",
Expand Down Expand Up @@ -120,6 +124,38 @@ class Migration(migrations.Migration):
verbose_name="audience heading",
),
),
migrations.AddField(
model_name="exhibitionpage",
name="body",
field=wagtail.fields.StreamField(
[("paragraph", 1), ("quote", 4)],
blank=True,
block_lookup={
0: (
"etna.core.blocks.paragraph.APIRichTextBlock",
(),
{"features": ["bold", "italic", "link", "ol", "ul"]},
),
1: ("wagtail.blocks.StructBlock", [[("text", 0)]], {}),
2: (
"etna.core.blocks.paragraph.APIRichTextBlock",
(),
{"features": ["bold", "italic", "link"], "required": True},
),
3: (
"wagtail.blocks.CharBlock",
(),
{"max_length": 100, "required": False},
),
4: (
"wagtail.blocks.StructBlock",
[[("quote", 2), ("attribution", 3)]],
{},
),
},
null=True,
),
),
migrations.AddField(
model_name="exhibitionpage",
name="booking_details",
Expand All @@ -135,6 +171,7 @@ class Migration(migrations.Migration):
name="event_links",
field=wagtail.fields.StreamField(
[("event_links", 5)],
blank=True,
block_lookup={
0: (
"wagtail.blocks.CharBlock",
Expand Down Expand Up @@ -162,9 +199,11 @@ class Migration(migrations.Migration):
model_name="exhibitionpage",
name="event_title",
field=models.CharField(
blank=True,
default="Exhibition events",
help_text="The title of the events section.",
max_length=100,
null=True,
verbose_name="event title",
),
),
Expand Down Expand Up @@ -423,7 +462,7 @@ class Migration(migrations.Migration):
1: (
"wagtail.blocks.CharBlock",
(),
{"max_length": 100, "required": False},
{"max_length": 100, "required": True},
),
2: (
"wagtail.blocks.ChoiceBlock",
Expand Down
24 changes: 13 additions & 11 deletions etna/whatson/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
MultiFieldPanel,
ObjectList,
TabbedInterface,
TitleFieldPanel,
)
from wagtail.api import APIField
from wagtail.fields import RichTextField, StreamField
Expand All @@ -37,13 +38,13 @@
from etna.core.models import (
AccentColourMixin,
BasePageWithRequiredIntro,
HeroStyleMixin,
HeroLayoutMixin,
HeroStyleMixin,
RequiredHeroImageMixin,
)
from etna.core.serializers import DefaultPageSerializer, RichTextSerializer

from .blocks import WhatsOnPromotedLinksBlock
from .blocks import ExhibitionPageStreamBlock, WhatsOnPromotedLinksBlock
from .forms import EventPageForm


Expand Down Expand Up @@ -851,11 +852,7 @@ class ExhibitionPage(
)

# Body section
description = RichTextField(
verbose_name=_("description"),
help_text=_("A description of the exhibition."),
features=settings.RESTRICTED_RICH_TEXT_FEATURES,
)
body = StreamField(ExhibitionPageStreamBlock, blank=True, null=True)

# email_signup = ...

Expand Down Expand Up @@ -901,12 +898,15 @@ class ExhibitionPage(
verbose_name=_("event title"),
help_text=_("The title of the events section."),
default="Exhibition events",
blank=True,
null=True,
)

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

shop = StreamField(
Expand Down Expand Up @@ -940,20 +940,22 @@ class Meta:
verbose_name_plural = _("exhibition pages")
verbose_name_public = _("exhibition")

content_panels = BasePageWithRequiredIntro.content_panels + [
content_panels = [
TitleFieldPanel("title"),
FieldPanel("subtitle"),
MultiFieldPanel(
[
FieldPanel("hero_image"),
FieldPanel("hero_image_caption"),
FieldPanel("hero_style"),
FieldPanel("hero_layout"),
FieldPanel("subtitle"),
],
heading=_("Hero section"),
),
MultiFieldPanel(
[
FieldPanel("description"),
FieldPanel("intro"),
FieldPanel("body"),
# FieldPanel("email_signup"),
FieldPanel("exhibition_highlights"),
FieldPanel("review"),
Expand Down Expand Up @@ -1045,7 +1047,7 @@ class Meta:
APIField("location_space_name"),
APIField("location_link_text"),
APIField("location_link_url"),
APIField("description", serializer=RichTextSerializer()),
APIField("body"),
# APIField("email_signup"),
APIField("exhibition_highlights"),
APIField("review"),
Expand Down

0 comments on commit 8aab118

Please sign in to comment.