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
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
Prev Previous commit
Next Next commit
Rename published_date to publication_date
kacperpONS committed Dec 11, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 7bad8a3ecef388d5ea915f5db34c56fefc4f949a
6 changes: 3 additions & 3 deletions cms/jinja2/templates/pages/methodology_page.html
Original file line number Diff line number Diff line change
@@ -27,10 +27,10 @@ <h1 class="ons-u-fs-3xl analysis-header__heading">
<div class="ons-container analysis-header__releases">
<div>
<span class="ons-u-fs-r--b analysis-header__releases-label">{{ _("Published") }}:</span>
<span class="ons-u-nowrap">{{ page.published_date|date("DATE_FORMAT") }}</span>
<span class="ons-u-nowrap">{{ page.publication_date|date("DATE_FORMAT") }}</span>
</div>
<div>
<span class="ons-u-fs-r--b analysis-header__releases-label">{{ _("Last revised:") }}:</span>
<span class="ons-u-fs-r--b analysis-header__releases-label">{{ _("Last revised") }}:</span>
<span class="ons-u-nowrap">{{ page.last_revised_date|date("DATE_FORMAT")}}</span>
</div>

@@ -97,7 +97,7 @@ <h2 class="ons-u-fs-l">{{ _("Cite this methodology") }}</h2>
{%- set cite_link -%}
<a href="{{ fullpageurl(page) }}">{{ page.title }}</a>
{% endset %}
{% set latest_date = page.last_revised_date if page.last_revised_date else page.published_date %}
{% set latest_date = page.last_revised_date if page.last_revised_date else page.publication_date %}
{% trans trimmed latest_date_formatted = latest_date|date("DATE_FORMAT"), cite_link=cite_link %}
Office for National Statistics (ONS), last revised {{ latest_date_formatted }}, ONS website, methodology, {{ cite_link }}
{% endtrans %}
2 changes: 1 addition & 1 deletion cms/methodology/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ class Migration(migrations.Migration):
('listing_summary', models.CharField(blank=True, max_length=255)),
('social_text', models.CharField(blank=True, max_length=255)),
('summary', wagtail.fields.RichTextField()),
('published_date', models.DateField()),
('publication_date', models.DateField()),
('last_revised_date', models.DateField(blank=True, null=True)),
('content', cms.core.fields.StreamField(block_lookup={})),
('show_cite_this_page', models.BooleanField(default=True)),
6 changes: 3 additions & 3 deletions cms/methodology/models.py
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ class MethodologyPage(BasePage): # type: ignore[django-manager-missing]
template = "templates/pages/methodology_page.html"

summary = RichTextField(features=settings.RICH_TEXT_BASIC)
published_date = models.DateField()
publication_date = models.DateField()
last_revised_date = models.DateField(blank=True, null=True)

contact_details = models.ForeignKey(
@@ -44,7 +44,7 @@ class MethodologyPage(BasePage): # type: ignore[django-manager-missing]
FieldPanel("summary"),
MultiFieldPanel(
[
FieldPanel("published_date", icon="calendar-date"),
FieldPanel("publication", icon="calendar-date"),
zerolab marked this conversation as resolved.
Show resolved Hide resolved
FieldPanel(
"last_revised_date",
),
@@ -68,7 +68,7 @@ def clean(self) -> None:
"""Additional validation on save."""
super().clean()

if self.last_revised_date and self.last_revised_date <= self.published_date:
if self.last_revised_date and self.last_revised_date <= self.publication_date:
raise ValidationError({"last_revised_date": _("The last revised date must be after the published date.")})

def get_context(self, request: "HttpRequest", *args: Any, **kwargs: Any) -> dict:
4 changes: 2 additions & 2 deletions cms/methodology/tests/factories.py
Original file line number Diff line number Diff line change
@@ -40,8 +40,8 @@ class Meta:
title = factory.Faker("sentence", nb_words=4)

summary = factory.Faker("text", max_nb_chars=100)
published_date = factory.LazyFunction(lambda: timezone.now().date())
last_revised_date = factory.LazyAttribute(lambda o: o.published_date + timedelta(days=1))
publication_date = factory.LazyFunction(lambda: timezone.now().date())
last_revised_date = factory.LazyAttribute(lambda o: o.publication_date + timedelta(days=1))
contact_details = factory.SubFactory(ContactDetailsFactory)

content = wagtail_factories.StreamFieldFactory({"section": factory.SubFactory(SectionBlockFactory)})
10 changes: 5 additions & 5 deletions cms/methodology/tests/test_models.py
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ def setUp(self):
self.basic_page = MethodologyPageFactory(
parent__title="Topic Page",
title="Methodology Page",
published_date=datetime(2024, 8, 15),
publication_date=datetime(2024, 8, 15),
show_cite_this_page=False,
contact_details=None,
)
@@ -27,7 +27,7 @@ def setUp(self):
self.page = MethodologyPageFactory(
zerolab marked this conversation as resolved.
Show resolved Hide resolved
parent__title="Topic Page",
title="Methodology Page",
published_date=datetime(2024, 8, 15),
publication_date=datetime(2024, 8, 15),
show_cite_this_page=True,
)
self.page_url = self.page.url
@@ -61,7 +61,7 @@ def test_cite_this_page_is_shown_when_ticked(self):

def test_cite_this_page_is_not_shown_when_unticked(self):
"""Test for the cite this page block not present in the template."""
self.basic_page.last_revised_date = self.basic_page.published_date + timezone.timedelta(days=1)
self.basic_page.last_revised_date = self.basic_page.publication_date + timezone.timedelta(days=1)
latest_date_formatted = date_format(self.basic_page.last_revised_date, settings.DATE_FORMAT)

expected = (
@@ -72,9 +72,9 @@ def test_cite_this_page_is_not_shown_when_unticked(self):
self.assertNotContains(response, expected)

# Dates
def test_last_revised_date_must_be_after_published_date(self):
def test_last_revised_date_must_be_after_publication_date(self):
"""Tests the model validates last revised date is after the publication date."""
self.page.last_revised_date = self.page.published_date
self.page.last_revised_date = self.page.publication_date

with self.assertRaises(ValidationError) as info:
self.page.clean()