Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Methodology page #57

Merged
merged 30 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ed52cc9
Refactorig to make the Section block reusable between apps
kacperpONS Dec 10, 2024
e4aaf3d
Page model, page HTML and a few TODOs
kacperpONS Dec 10, 2024
430e236
Merge branch 'main' into methodology-page-CMS-200
kacperpONS Dec 10, 2024
74f5448
Renamed to SectionStoryBlock and moved to stream_blocks.py
kacperpONS Dec 10, 2024
5650515
Renamed Related content to Related publications in the template
kacperpONS Dec 11, 2024
54c647f
Added index for search
kacperpONS Dec 11, 2024
e4e6893
Removed the methodology_summary field - future requirement when in DS
kacperpONS Dec 11, 2024
3f6c6cc
Restrict to only allow Methodology under Topic page
kacperpONS Dec 11, 2024
584191b
Added tests, date validation and minor fixes
kacperpONS Dec 11, 2024
0d6c077
Added migration file
kacperpONS Dec 11, 2024
fc9b1ac
Formatting
kacperpONS Dec 11, 2024
bc5136f
Extract methodology into its own app
kacperpONS Dec 11, 2024
7bad8a3
Rename published_date to publication_date
kacperpONS Dec 11, 2024
2ce7a72
Section blocks - changed the fields order, moved block_counts + forma…
kacperpONS Dec 11, 2024
1ea7ed1
A bunch of small fixes
kacperpONS Dec 11, 2024
f21fbdd
Put the date panels in a FieldRowPanel
kacperpONS Dec 11, 2024
96e07a6
Make CoreStoryBlock and SectionStoryBlock separate again
kacperpONS Dec 12, 2024
13211ed
Added test for external env (+formatting)
kacperpONS Dec 12, 2024
62ddaf1
Wrapped Last revised date in a conditional in the template
kacperpONS Dec 17, 2024
539a1d3
Move Section Block Factories to the core app's tests
kacperpONS Dec 17, 2024
5690c11
Formatted the date input panels code (+ removed the redundant FieldPa…
kacperpONS Dec 18, 2024
4109c3b
Merge branch 'main' into methodology-page-CMS-200
kacperpONS Dec 18, 2024
ff99288
Merge branch 'main' into methodology-page-CMS-200
zerolab Jan 8, 2025
2141b87
Tidy up tests
zerolab Jan 8, 2025
028d806
Make related publications specific to Methodology page and limited to…
zerolab Jan 8, 2025
a498b4d
Minor tidy ups
zerolab Jan 8, 2025
5b58b6e
Merge branch 'main' into methodology-page-CMS-200
zerolab Jan 8, 2025
765705e
Update the methodology page template post #55
zerolab Jan 8, 2025
ac4bed3
Tidy up the related publications output
zerolab Jan 9, 2025
8a96fd0
Merge branch 'main' into methodology-page-CMS-200
zerolab Jan 9, 2025
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
4 changes: 2 additions & 2 deletions cms/analysis/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
from wagtail.models import Page
from wagtail.search import index

from cms.analysis.blocks import AnalysisStoryBlock
from cms.bundles.models import BundledPageMixin
from cms.core.blocks import HeadlineFiguresBlock
from cms.core.blocks.section_block import SectionStreamBlock
from cms.core.fields import StreamField
from cms.core.models import BasePage

Expand Down Expand Up @@ -120,7 +120,7 @@ class AnalysisPage(BundledPageMixin, BasePage): # type: ignore[django-manager-m

# Fields: content
headline_figures = StreamField([("figures", HeadlineFiguresBlock())], blank=True, max_num=1)
content = StreamField(AnalysisStoryBlock())
content = StreamField(SectionStreamBlock())

show_cite_this_page = models.BooleanField(default=True)

Expand Down
24 changes: 12 additions & 12 deletions cms/analysis/blocks.py → cms/core/blocks/section_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
from wagtail.images.blocks import ImageChooserBlock
from wagtailmath.blocks import MathBlock

if TYPE_CHECKING:
from wagtail.blocks import StructValue

from cms.core.blocks import (
DocumentsBlock,
HeadingBlock,
Expand All @@ -15,42 +18,39 @@
RelatedLinksBlock,
)

if TYPE_CHECKING:
from wagtail.blocks import StructValue


class SectionContentBlock(StreamBlock):
"""The analysis section content StreamField block definition."""
"""The core section content block definition."""

rich_text = RichTextBlock()
panel = PanelBlock()
embed = EmbedBlock(group="Media")
image = ImageChooserBlock(group="Media")
documents = DocumentsBlock(group="Media")
embed = EmbedBlock(group="Media")
related_links = RelatedLinksBlock(RelatedContentBlock(), icon="link")
equation = MathBlock(group="DataVis", icon="decimal")
ons_embed = ONSEmbedBlock(group="DataVis", label="ONS General Embed")
related_links = RelatedLinksBlock(RelatedContentBlock(), icon="link")

class Meta:
template = "templates/components/streamfield/stream_block.html"
block_counts: ClassVar[dict[str, dict]] = {"related_links": {"max_num": 1}}


class SectionBlock(StructBlock):
"""The analysis section block definition."""
"""The core section block definition with headers."""

title = HeadingBlock()
content = SectionContentBlock()

class Meta:
block_counts: ClassVar[dict[str, dict]] = {"related_links": {"max_num": 1}}
template = "templates/components/streamfield/section_with_header_block.html"

def to_table_of_contents_items(self, value: "StructValue") -> list[dict[str, str]]:
"""Convert the value to the table of contents component macro format."""
return [{"url": "#" + slugify(value["title"]), "text": value["title"]}]

class Meta:
template = "templates/components/streamfield/analysis_section_block.html"


class AnalysisStoryBlock(StreamBlock):
class SectionStreamBlock(StreamBlock):
zerolab marked this conversation as resolved.
Show resolved Hide resolved
"""The analysis StreamField block definition."""

section = SectionBlock()
Expand Down
31 changes: 0 additions & 31 deletions cms/core/blocks/stream_blocks.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ <h2 class="ons-u-fs-l">{{ value.title }}</h2>

{% include_block value.content %}
</section>

1 change: 1 addition & 0 deletions cms/jinja2/templates/pages/methodology_page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% extends "templates/base_page.html" %}
Loading