Skip to content

Commit c612397

Browse files
rzarroukjamesbiggs
andauthored
ED-16: Feature/education skeleton pages (#1959)
Co-authored-by: James Biggs <62654785+jamesbiggs@users.noreply.github.com> Co-authored-by: jamesbiggs <james.biggs@nationalarchives.gov.uk>
1 parent 94a7316 commit c612397

19 files changed

Lines changed: 2051 additions & 2 deletions

app/core/blocks/__init__.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,17 @@
66
from .featured_content import (
77
FeaturedCollectionBlock,
88
)
9-
from .image import ContentImageBlock, ImageGalleryBlock, PartnerLogoListBlock
9+
from .image import (
10+
APIImageChooserBlock,
11+
ContentImageBlock,
12+
ImageGalleryBlock,
13+
PartnerLogoChooserBlock,
14+
PartnerLogoListBlock,
15+
)
1016
from .lists import DescriptionListBlock, DoDontListBlock, PeopleListingBlock
1117
from .page_chooser import APIPageChooserBlock
1218
from .page_list import PageListBlock
13-
from .paragraph import ParagraphBlock
19+
from .paragraph import APIRichTextBlock, ParagraphBlock
1420
from .promoted_links import (
1521
FeaturedExternalLinkBlock,
1622
FeaturedPageBlock,
@@ -24,6 +30,8 @@
2430
from .video import MixedMediaBlock, YouTubeBlock
2531

2632
__all__ = [
33+
"APIImageChooserBlock",
34+
"APIRichTextBlock",
2735
"APIPageChooserBlock",
2836
"AccordionsBlock",
2937
"ButtonBlock",
@@ -46,6 +54,7 @@
4654
"MixedMediaBlock",
4755
"PageListBlock",
4856
"ParagraphBlock",
57+
"PartnerLogoChooserBlock",
4958
"PartnerLogoListBlock",
5059
"PeopleListingBlock",
5160
"QuoteBlock",

app/core/blocks/image.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ def get_api_representation(self, value, context=None):
4949
)
5050
return serializer.to_representation(value)
5151

52+
class Meta:
53+
group = "Video, audio and downloads"
54+
5255

5356
class ContentImageBlock(blocks.StructBlock):
5457
image = APIImageChooserBlock(rendition_size="max-900x900", required=True)

app/core/blocks/paragraph.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ def get_api_representation(self, value, context=None):
88
representation = super().get_api_representation(value, context)
99
return expand_db_html(representation)
1010

11+
class Meta:
12+
group = "Basic text"
13+
1114

1215
class ParagraphBlock(blocks.StructBlock):
1316
text = APIRichTextBlock(features=settings.RESTRICTED_RICH_TEXT_FEATURES)

app/education/__init__.py

Whitespace-only changes.

app/education/apps.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from django.apps import AppConfig
2+
3+
4+
class EducationConfig(AppConfig):
5+
default_auto_field = "django.db.models.AutoField"
6+
name = "app.education"
7+
verbose_name = "Education"

app/education/blocks.py

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
from django.conf import settings
2+
from wagtail import blocks
3+
4+
from app.core.blocks import (
5+
APIImageChooserBlock,
6+
APIRichTextBlock,
7+
FeaturedExternalLinkBlock,
8+
FeaturedPageBlock,
9+
InsetTextBlock,
10+
ParagraphBlock,
11+
PartnerLogoChooserBlock,
12+
QuoteBlock,
13+
YouTubeBlock,
14+
)
15+
from app.media.blocks import MediaBlock
16+
17+
# Resources - Source
18+
19+
20+
class SourceImageWithCaptionBlock(blocks.StructBlock):
21+
image = APIImageChooserBlock(
22+
rendition_size="max-900x900",
23+
help_text="An image for the source.",
24+
)
25+
caption = APIRichTextBlock(features=["bold", "italic"], required=False)
26+
27+
class Meta:
28+
group = "Video, audio and downloads"
29+
30+
31+
class SourceMediaWithCaptionBlock(MediaBlock):
32+
title = None
33+
caption = APIRichTextBlock(features=["bold", "italic"], required=False)
34+
35+
36+
class SourceYouTubeWithCaptionBlock(MediaBlock):
37+
youtube = YouTubeBlock()
38+
caption = APIRichTextBlock(features=["bold", "italic"], required=False)
39+
40+
class Meta:
41+
label = "YouTube"
42+
43+
44+
class SourceMediaBlock(blocks.StreamBlock):
45+
image = SourceImageWithCaptionBlock()
46+
video = SourceMediaWithCaptionBlock()
47+
youtube = SourceYouTubeWithCaptionBlock()
48+
49+
class Meta:
50+
label = "Source media"
51+
52+
53+
class SourceFeaturedLinkBlock(blocks.StreamBlock):
54+
external_link = FeaturedExternalLinkBlock()
55+
internal_link = FeaturedPageBlock()
56+
57+
class Meta:
58+
label = "Source featured link"
59+
60+
61+
class SourceQuestionItemBlock(blocks.StructBlock):
62+
question_heading = blocks.CharBlock(
63+
required=False,
64+
max_length=255,
65+
)
66+
question_description = APIRichTextBlock(
67+
features=settings.RESTRICTED_RICH_TEXT_FEATURES,
68+
required=False,
69+
)
70+
71+
class Meta:
72+
icon = "help"
73+
label = "Question"
74+
75+
76+
class SourceQuestionBlock(blocks.StreamBlock):
77+
question = SourceQuestionItemBlock()
78+
79+
class Meta:
80+
label = "Source question"
81+
82+
83+
class SectionContentBlock(blocks.StreamBlock):
84+
description = ParagraphBlock()
85+
partner_logo = PartnerLogoChooserBlock()
86+
quote = QuoteBlock()
87+
inset_text = InsetTextBlock()
88+
89+
90+
class SessionDescriptionBlock(blocks.StructBlock):
91+
heading = blocks.CharBlock(max_length=100, label="Heading")
92+
content = SectionContentBlock(required=False)
93+
94+
class Meta:
95+
label = "Section"
96+
group = "Basic text"

app/education/migrations/0001_initial.py

Lines changed: 366 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# etna:allowAlterField
2+
3+
4+
from django.db import migrations
5+
6+
KEY_STAGES = [
7+
("key-stage-1", "Key stage 1", 1, "5-7"),
8+
("key-stage-2", "Key stage 2", 2, "7-11"),
9+
("key-stage-3", "Key stage 3", 3, "11-14"),
10+
("key-stage-4", "Key stage 4", 4, "14-16"),
11+
("key-stage-5", "Key stage 5", 5, "16-18"),
12+
]
13+
14+
THEMES = [
15+
("power-politics-and-reform", "Power, politics and reform"),
16+
("war-and-revolution", "War and revolution"),
17+
("migration-and-identity", "Migration and identity"),
18+
("empire-and-decolonisation", "Empire and decolonisation"),
19+
("crime-and-punishment", "Crime and punishment"),
20+
("medicine-welfare-and-society", "Medicine, welfare and society"),
21+
("family-community-and-everyday-life", "Family, community and everyday life"),
22+
("economy-trade-and-industry", "Economy, trade and industry"),
23+
("archive-skills", "Archive skills"),
24+
("local-history", "Local history"),
25+
("womens-history", "Women's history"),
26+
("black-asian-and-global-majority-history", "Black, Asian and global majority history"),
27+
("lgbtq-history", "LGBTQ+ history"),
28+
("disability-history", "Disability history"),
29+
("significant-people-places-and-events", "Significant people, places and events"),
30+
]
31+
32+
# Tuple: (slug, name, year_from, year_to, available_for_resources)
33+
TIME_PERIODS = [
34+
("early-civilisations", "Early civilisations", None, 900, False),
35+
("medieval", "Medieval", 900, 1485, True),
36+
("early-modern", "Early modern", 1485, 1750, True),
37+
("industrial-revolution", "Industrial revolution", 1750, 1901, True),
38+
("early-twentieth-century", "Early Twentieth Century", 1901, 1945, True),
39+
("post-war-and-modern", "Post-War and modern", 1945, None, True),
40+
("cross-period", "Cross period", None, None, True),
41+
]
42+
43+
44+
def seed_key_stages(apps, schema_editor):
45+
KeyStage = apps.get_model("education", "KeyStage")
46+
key_stage_field_names = {field.name for field in KeyStage._meta.fields}
47+
48+
for slug, name, stage, age_range in KEY_STAGES:
49+
defaults = {"name": name}
50+
defaults["stage"] = stage
51+
defaults["age_range"] = age_range
52+
53+
KeyStage.objects.update_or_create(
54+
slug=slug,
55+
defaults=defaults,
56+
)
57+
58+
59+
def seed_themes(apps, schema_editor):
60+
Theme = apps.get_model("education", "Theme")
61+
62+
for slug, name in THEMES:
63+
Theme.objects.update_or_create(
64+
slug=slug,
65+
defaults={"name": name},
66+
)
67+
68+
69+
def seed_time_periods(apps, schema_editor):
70+
TimePeriod = apps.get_model("education", "TimePeriod")
71+
time_period_field_names = {field.name for field in TimePeriod._meta.fields}
72+
73+
for slug, name, year_from, year_to, available_for_resources in TIME_PERIODS:
74+
defaults = {"name": name}
75+
76+
if "year_from" in time_period_field_names:
77+
defaults["year_from"] = year_from
78+
79+
if "year_to" in time_period_field_names:
80+
defaults["year_to"] = year_to
81+
82+
if "available_for_resources" in time_period_field_names:
83+
defaults["available_for_resources"] = available_for_resources
84+
85+
TimePeriod.objects.update_or_create(
86+
slug=slug,
87+
defaults=defaults,
88+
)
89+
90+
91+
def seed_education_taxonomies(apps, schema_editor):
92+
seed_key_stages(apps, schema_editor)
93+
seed_themes(apps, schema_editor)
94+
seed_time_periods(apps, schema_editor)
95+
96+
97+
def noop_reverse(apps, schema_editor):
98+
pass
99+
100+
101+
class Migration(migrations.Migration):
102+
dependencies = [
103+
("education", "0001_initial"),
104+
]
105+
106+
operations = [
107+
migrations.RunPython(seed_education_taxonomies, noop_reverse),
108+
]

app/education/migrations/__init__.py

Whitespace-only changes.

app/education/models/__init__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from .landing import EducationPage
2+
from .listings import (
3+
EducationSessionsListingPage,
4+
TeachingResourcesListingPage,
5+
)
6+
from .resources import TeachingResourcePage
7+
from .sessions import EducationSessionPage
8+
9+
__all__ = [
10+
"EducationPage",
11+
"TeachingResourcePage",
12+
"EducationSessionPage",
13+
"EducationSessionsListingPage",
14+
"TeachingResourcesListingPage",
15+
]

0 commit comments

Comments
 (0)