Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions backend/api/cms/home/blocks/home_intro_section.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ class HomeIntroSection:
id: strawberry.ID
pretitle: str
title: str
subtitle: str

@classmethod
def from_block(cls, block) -> Self:
return cls(
id=block.id,
pretitle=block.value["pretitle"],
title=block.value["title"],
subtitle=block.value["subtitle"],
)
57 changes: 57 additions & 0 deletions backend/api/cms/tests/page/queries/test_cms_page.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
from decimal import Decimal
from conferences.tests.factories import ConferenceFactory
import pytest
Expand Down Expand Up @@ -70,6 +71,62 @@ def test_page(graphql_client, locale):
}


def test_home_intro_section_subtitle(graphql_client, locale):
parent = GenericPageFactory()
page = GenericPageFactory(
slug="home",
locale=locale("en"),
parent=parent,
body=json.dumps(
[
{
"type": "home_intro_section",
"id": "with-subtitle",
"value": {
"pretitle": "Pretitle",
"title": "Title",
"subtitle": "Subtitle",
},
},
{
"type": "home_intro_section",
"id": "saved-before-subtitle-existed",
"value": {"pretitle": "Pretitle", "title": "Title"},
},
]
),
)
page.save_revision().publish()
SiteFactory(hostname="pycon", port=80, root_page=parent)
query = """
query Page ($hostname: String!, $language: String!, $slug: String!) {
cmsPage(hostname: $hostname, language: $language, slug: $slug){
...on GenericPage {
body {
...on HomeIntroSection {
title
subtitle
}
}
}
}
}
"""

response = graphql_client.query(
query, variables={"hostname": "pycon", "slug": "home", "language": "en"}
)

assert response["data"] == {
"cmsPage": {
"body": [
{"title": "Title", "subtitle": "Subtitle"},
{"title": "Title", "subtitle": ""},
]
}
}


def test_page_with_ticket_restriction_and_ticket_returns_content(
graphql_client, locale, user, mock_has_ticket
):
Expand Down
1 change: 1 addition & 0 deletions backend/cms/components/home/blocks/home_intro_section.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
class HomeIntroSection(blocks.StructBlock):
pretitle = blocks.CharBlock(required=False)
title = blocks.CharBlock(required=False)
subtitle = blocks.CharBlock(required=False, default="")

class Meta:
label = "Homepage: Intro section"
Expand Down
Loading