Skip to content

Commit b844e57

Browse files
Remove LeadershipPage Model [WT-1389]
1 parent 32f750f commit b844e57

4 files changed

Lines changed: 48 additions & 144 deletions

File tree

bedrock/mozorg/blocks/leadership.py

Lines changed: 0 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,11 @@
33
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
44

55
from django.conf import settings
6-
from django.template.defaultfilters import slugify as django_slugify
76

87
from wagtail import blocks
9-
from wagtail.images.blocks import ImageChooserBlock
108
from wagtail.snippets.blocks import SnippetChooserBlock
119

1210

13-
class LeadershipHeadshotBlock(blocks.StructBlock):
14-
"""Block for a leadership bio headshot image and (optional) photos link."""
15-
16-
image = ImageChooserBlock(
17-
help_text="A headshot image of the person.",
18-
)
19-
20-
image_alt_text = blocks.CharBlock(
21-
char_max_length=255,
22-
help_text="Alt text for the headshot image.",
23-
)
24-
25-
photos_link = blocks.URLBlock(
26-
required=False,
27-
char_max_length=255,
28-
help_text="External link to a .zip file of photos of the person.",
29-
)
30-
31-
class Meta:
32-
icon = "image"
33-
label = "Headshot image"
34-
35-
3611
class LeadershipExternalLinkBlock(blocks.StructBlock):
3712
"""Block for a leadership bio external link, such as a website or social media account."""
3813

@@ -63,105 +38,6 @@ class Meta:
6338
label = "External Link"
6439

6540

66-
class LeadershipBioID(blocks.StructValue):
67-
"""ID Value class for LeadershipBioBlock. Used for page anchor links."""
68-
69-
@property
70-
def id(self):
71-
name = self.get("name")
72-
return django_slugify(name)
73-
74-
75-
class LeadershipBioBlock(blocks.StructBlock):
76-
"""Block for a leadership bio."""
77-
78-
name = blocks.CharBlock(
79-
char_max_length=255,
80-
placeholder="Enter the person's full name.",
81-
)
82-
83-
headshot = LeadershipHeadshotBlock()
84-
85-
job_title = blocks.CharBlock(
86-
required=False,
87-
char_max_length=255,
88-
)
89-
90-
biography = blocks.RichTextBlock(
91-
required=False,
92-
help_text="A biography limited to a few short paragraphs. Links and formatting are supported.",
93-
features=settings.WAGTAIL_RICHTEXT_FEATURES_FULL,
94-
)
95-
96-
external_links = blocks.ListBlock(
97-
LeadershipExternalLinkBlock(),
98-
min_num=0,
99-
max_num=5,
100-
)
101-
102-
class Meta:
103-
value_class = LeadershipBioID
104-
template = "mozorg/cms/about/blocks/leadership_block.html"
105-
icon = "user"
106-
label = "Leadership Profile"
107-
108-
109-
class LeadershipGroupBlock(blocks.StructBlock):
110-
"""Block for a leadership group."""
111-
112-
title = blocks.CharBlock(
113-
char_max_length=255,
114-
help_text="Leadership group title, e.g. 'Executive Steering Committee' or 'Senior Leadership'.",
115-
required=False,
116-
)
117-
118-
description = blocks.CharBlock(
119-
char_max_length=1000,
120-
help_text="A couple of sentences describes what the group is and some helpful context.",
121-
required=False,
122-
)
123-
124-
leaders = blocks.ListBlock(
125-
LeadershipBioBlock(),
126-
min_num=1,
127-
)
128-
129-
class Meta:
130-
icon = "group"
131-
132-
133-
class LeadershipSectionID(blocks.StructValue):
134-
"""ID Value class for LeadershipSectionBlock. Used for page anchor links."""
135-
136-
@property
137-
def id(self):
138-
name = self.get("title")
139-
return django_slugify(name)
140-
141-
142-
class LeadershipSectionBlock(blocks.StructBlock):
143-
"""Block for a leadership section containing a title and one or more leadership groups."""
144-
145-
title = blocks.CharBlock(
146-
max_length=255, blank=True, null=True, help_text="Title for the section of the page e.g. 'Mozilla Corporation' or 'Mozilla Foundation."
147-
)
148-
149-
description = blocks.CharBlock(
150-
char_max_length=1000,
151-
help_text="Description for the leadership section.",
152-
required=False,
153-
)
154-
155-
leadership_group = blocks.ListBlock(
156-
LeadershipGroupBlock(),
157-
min_num=1,
158-
)
159-
160-
class Meta:
161-
value_class = LeadershipSectionID
162-
icon = "group"
163-
164-
16541
class LeadershipProfileChooserBlock(blocks.StructBlock):
16642
"""Block for placing a LeadershipProfileSnippet with an optional per-placement job title."""
16743

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
5+
# Generated by Django 5.2.14 on 2026-06-30 19:08
6+
7+
from django.db import migrations
8+
9+
10+
class Migration(migrations.Migration):
11+
12+
dependencies = [
13+
('mozorg', '0042_alter_organizationleadershipsubpage_leadership_groups'),
14+
]
15+
16+
operations = [
17+
migrations.DeleteModel(
18+
name='LeadershipPage',
19+
),
20+
]
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
5+
from django.db import migrations
6+
7+
STALE_MODELS = (
8+
"LeadershipPage",
9+
)
10+
11+
12+
def remove_stale_contenttypes(apps, schema_editor):
13+
# Migration 0043 dropped LeadershipPage
14+
# but Django doesn't auto-purge the django_content_type rows for deleted models. Anything
15+
# that resolves a log entry / permission via ContentType.get_object_for_this_type() (e.g.
16+
# the Wagtail admin home recent-edits panel) then crashes because model_class() is None.
17+
ContentType = apps.get_model("contenttypes", "ContentType")
18+
ContentType.objects.filter(app_label="cms", model__in=STALE_MODELS).delete()
19+
20+
21+
class Migration(migrations.Migration):
22+
dependencies = [
23+
("mozorg", "0043_delete_leadershippage"),
24+
]
25+
26+
operations = [
27+
migrations.RunPython(remove_stale_contenttypes, reverse_code=migrations.RunPython.noop),
28+
]

bedrock/mozorg/models.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
LeadershipExternalLinkBlock,
2828
LeadershipGroupSnippetBlock,
2929
LeadershipProfileChooserBlock,
30-
LeadershipSectionBlock,
3130
)
3231
from bedrock.mozorg.blocks.navigation import NavigationLinkBlock
3332

@@ -329,25 +328,6 @@ def __str__(self):
329328
return self.name
330329

331330

332-
class LeadershipPage(AbstractBedrockCMSPage):
333-
max_count = 1 # Ensure there's only one instance of this page
334-
subpage_types = [] # This page type cannot have any children
335-
336-
leadership_sections = StreamField(
337-
[("section", LeadershipSectionBlock())],
338-
blank=True,
339-
null=True,
340-
collapsed=True,
341-
use_json_field=True,
342-
)
343-
344-
content_panels = AbstractBedrockCMSPage.content_panels + [
345-
FieldPanel("leadership_sections"),
346-
]
347-
348-
template = "mozorg/cms/about/leadership.html"
349-
350-
351331
class OrganizationLeadershipIndexPage(AbstractBedrockCMSPage):
352332
subpage_types = ["OrganizationLeadershipSubpage"]
353333

0 commit comments

Comments
 (0)