Skip to content

Commit 50b07fa

Browse files
authored
Merge branch 'main' into task/CDD-3154-seed-random-data
2 parents bfc90dc + 61a29ea commit 50b07fa

File tree

13 files changed

+1401
-10
lines changed

13 files changed

+1401
-10
lines changed

.github/workflows/actions.yml

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
name: Pipeline
22

3-
on: push
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- '*'
410

511
env:
612
APIENV: "LOCAL"
@@ -172,6 +178,23 @@ jobs:
172178
source uhd.sh
173179
uhd tests coverage
174180
181+
###############################################################################
182+
# Docker build check (PR validation)
183+
###############################################################################
184+
185+
docker-build-check:
186+
name: Docker Build Check
187+
needs: [build]
188+
runs-on: ubuntu-22.04-arm
189+
steps:
190+
- uses: actions/checkout@v4
191+
192+
- name: Build main API Docker image
193+
run: docker build -t be-main-test -f Dockerfile .
194+
195+
- name: Build ingestion Docker image
196+
run: docker build -t be-ingestion-test -f Dockerfile-ingestion .
197+
175198
###############################################################################
176199
# Build image
177200
###############################################################################
@@ -187,7 +210,8 @@ jobs:
187210
test-coverage,
188211
dependency-checks,
189212
vulnerability-checks,
190-
architecture-checks
213+
architecture-checks,
214+
docker-build-check
191215
]
192216
runs-on: ubuntu-22.04-arm
193217
if: ${{ github.ref == 'refs/heads/main' }}
@@ -212,7 +236,8 @@ jobs:
212236
test-coverage,
213237
dependency-checks,
214238
vulnerability-checks,
215-
architecture-checks
239+
architecture-checks,
240+
docker-build-check
216241
]
217242
runs-on: ubuntu-22.04-arm
218243
if: ${{ github.ref == 'refs/heads/main' }}

.python-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.12
1+
3.12.13

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Default arguments
55
# This version is hardcoded but ideally it should pull from the `.python-version`
66
# When bumping Python versions, we currently have to update the `.python-version` file and this `ARG`
7-
ARG PYTHON_VERSION=3.12.6
7+
ARG PYTHON_VERSION=3.12.13
88

99
FROM python:${PYTHON_VERSION}-slim AS build
1010

@@ -18,7 +18,7 @@ COPY requirements-prod-ingestion.txt requirements-prod-ingestion.txt
1818
# Main build process
1919
RUN apt-get update \
2020
# Update the database of available packages
21-
&& apt-get -y install libpq-dev gcc \
21+
&& apt-get -y install libpq-dev gcc libnss3-dev libexpat1-dev\
2222
# Install toolchain needed for C libraries like `psycopg2`
2323
&& python3 -m venv /venv \
2424
# Create the python virtual environment
@@ -55,7 +55,7 @@ EXPOSE 8000
5555
# Reinstall system libraries required for PostgreSQL drivers
5656
RUN apt-get update \
5757
# Update the database of available packages
58-
&& apt-get -y install libpq-dev \
58+
&& apt-get -y install libpq-dev libnss3-dev libexpat1-dev\
5959
# Reinstall the C library needed for `psycopg2`
6060
&& chmod +x entrypoint.sh
6161
# Add execution permission for the entrypoint shell script

cms/dynamic_content/blocks.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from django.core.exceptions import ValidationError
12
from django.db import models
23
from wagtail import blocks
34
from wagtail.snippets.blocks import SnippetChooserBlock
@@ -8,6 +9,7 @@
89
PercentageNumberComponent,
910
TrendNumberComponent,
1011
)
12+
from validation.url import validate_https_scheme
1113

1214
MINIMUM_ROWS_NUMBER_BLOCK_COUNT: int = 1
1315
MAXIMUM_ROWS_NUMBER_BLOCK_COUNT: int = 2
@@ -161,3 +163,38 @@ class RelatedLink(blocks.StructBlock):
161163

162164
class RelatedLinkBlock(blocks.StreamBlock):
163165
related_link = RelatedLink()
166+
167+
168+
class SourceLinkBlock(blocks.StructBlock):
169+
"""Source link supporting internal (page) or external (URL) links."""
170+
171+
link_display_text = blocks.CharBlock(
172+
required=False,
173+
help_text=help_texts.SOURCE_LINK_TEXT,
174+
)
175+
page = PageLinkChooserBlock(
176+
target_model=["topic.TopicPage"],
177+
required=False,
178+
help_text=help_texts.SOURCE_LINK_PAGE,
179+
)
180+
external_url = blocks.URLBlock(
181+
required=False,
182+
help_text=help_texts.SOURCE_LINK_URL,
183+
validators=[validate_https_scheme],
184+
)
185+
186+
def clean(self, value: blocks.StructValue):
187+
self._validate_only_one_of_page_or_external_url(value=value)
188+
return super().clean(value=value)
189+
190+
@classmethod
191+
def _validate_only_one_of_page_or_external_url(
192+
cls, *, value: blocks.StructValue
193+
) -> None:
194+
"""Validate that only one of the page or external_url fields is set if provided."""
195+
page = value.get("page")
196+
external_url = value.get("external_url")
197+
198+
if page and external_url:
199+
error_message = "Use either page OR external_url, not both."
200+
raise ValidationError(error_message)

cms/dynamic_content/cards.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
MetricNumberBlock,
1414
PageLinkChooserBlock,
1515
RelatedLinkBlock,
16+
SourceLinkBlock,
1617
)
1718
from cms.dynamic_content.components import (
1819
ChartComponent,
@@ -76,11 +77,19 @@ def get_alerts(cls) -> tuple[tuple[str, str]]:
7677
class WeatherHealthAlertsCard(blocks.StructBlock):
7778
title = blocks.TextBlock(required=True, help_text=help_texts.TITLE_FIELD)
7879
sub_title = blocks.TextBlock(required=True, help_text=help_texts.SUB_TITLE_FIELD)
80+
description = blocks.TextBlock(
81+
required=False,
82+
help_text=help_texts.WEATHER_HEALTH_ALERT_DESCRIPTION,
83+
)
7984
alert_type = blocks.ChoiceBlock(
8085
required=True,
8186
choices=WHAlerts.get_alerts,
8287
help_text=help_texts.WHA_ALERT_CHOICE,
8388
)
89+
source = SourceLinkBlock(
90+
required=False,
91+
help_text=help_texts.SOURCE_LINK,
92+
)
8493

8594
class Meta:
8695
icon = "weather"
@@ -295,6 +304,20 @@ class Meta:
295304
icon = "standalone_chart"
296305

297306

307+
class ChartWithDescriptionCard(ChartCard):
308+
description = blocks.TextBlock(
309+
required=True,
310+
help_text=help_texts.CHART_DESCRIPTION,
311+
)
312+
source = SourceLinkBlock(
313+
required=False,
314+
help_text=help_texts.SOURCE_LINK_INTERNAL_OR_EXTERNAL,
315+
)
316+
317+
class Meta:
318+
icon = "standalone_chart"
319+
320+
298321
class HeadlineChartCard(ChartCard):
299322
x_axis = blocks.ChoiceBlock(
300323
required=True,
@@ -338,6 +361,20 @@ class Meta:
338361
icon = "standalone_chart"
339362

340363

364+
class HeadlineChartWithDescriptionCard(HeadlineChartCard):
365+
description = blocks.TextBlock(
366+
required=True,
367+
help_text=help_texts.HEADLINE_CHART_DESCRIPTION,
368+
)
369+
source = SourceLinkBlock(
370+
required=False,
371+
help_text=help_texts.SOURCE_LINK_INTERNAL_OR_EXTERNAL,
372+
)
373+
374+
class Meta:
375+
icon = "standalone_chart"
376+
377+
341378
class DualCategoryChartCard(blocks.StructBlock):
342379
title = blocks.TextBlock(required=True, help_text=help_texts.TITLE_FIELD)
343380
body = blocks.TextBlock(
@@ -445,7 +482,9 @@ def media(self):
445482

446483
class ChartRowBlockTypes(blocks.StreamBlock):
447484
chart_card = ChartCard()
485+
chart_with_description_card = ChartWithDescriptionCard()
448486
headline_chart_card = HeadlineChartCard()
487+
headline_chart_with_description_card = HeadlineChartWithDescriptionCard()
449488
chart_with_headline_and_trend_card = ChartWithHeadlineAndTrendCard()
450489
simplified_chart_with_link = SimplifiedChartWithLink()
451490
dual_category_chart_card = DualCategoryChartCard()

cms/dynamic_content/help_texts.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,3 +552,35 @@
552552
An optional body of text to accompany this block.
553553
This text will be displayed above the metrics table if confidence intervals is enabled.
554554
"""
555+
556+
WEATHER_HEALTH_ALERT_DESCRIPTION: str = """
557+
Optional description for the weather health alerts card.
558+
"""
559+
560+
SOURCE_LINK: str = """
561+
Optional source link.
562+
"""
563+
564+
CHART_DESCRIPTION: str = """
565+
Required description for the chart.
566+
"""
567+
568+
HEADLINE_CHART_DESCRIPTION: str = """
569+
Description for the headline chart.
570+
"""
571+
572+
SOURCE_LINK_INTERNAL_OR_EXTERNAL: str = """
573+
Source link (internal or external).
574+
"""
575+
576+
SOURCE_LINK_TEXT: str = """
577+
Display text for the link.
578+
"""
579+
580+
SOURCE_LINK_PAGE: str = """
581+
For linking to internal pages. (If chosen, external_url must be blank).
582+
"""
583+
584+
SOURCE_LINK_URL: str = """
585+
For linking to external url. (Only one of page or external_url must be filled not both).
586+
"""

0 commit comments

Comments
 (0)