Skip to content

Remove LeadershipPage Model [WT-1389]#17266

Draft
stephaniehobson wants to merge 1 commit into
mozorg-cleanupfrom
mozorg-model-cleanup
Draft

Remove LeadershipPage Model [WT-1389]#17266
stephaniehobson wants to merge 1 commit into
mozorg-cleanupfrom
mozorg-model-cleanup

Conversation

@stephaniehobson

Copy link
Copy Markdown
Contributor

One-line summary

Removes the retired LeadershipPage model and block and deletes them from the content table.

Significant changes and points to review

Issue / Bugzilla link

[WT-1389]

Testing

NOTE: this PR depends on #17253

@stevejalim stevejalim requested a review from Copilot July 1, 2026 09:24

@stevejalim stevejalim left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - thanks. Let's wait to merge this until we can ship it as a single-changeset release

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Removes the retired Wagtail LeadershipPage model and legacy leadership StreamField block implementations from mozorg, and adds migrations to drop the model plus clean up the associated django_content_type row to prevent Wagtail admin lookups from failing.

Changes:

  • Remove LeadershipPage from bedrock/mozorg/models.py.
  • Remove legacy leadership page block definitions from bedrock/mozorg/blocks/leadership.py, leaving only the snippet-based blocks.
  • Add migrations to delete the LeadershipPage model and to purge the stale django_content_type entry.

Note: Review performed following the repository’s custom Copilot instructions.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
bedrock/mozorg/models.py Removes the retired LeadershipPage model definition and its use of LeadershipSectionBlock.
bedrock/mozorg/blocks/leadership.py Deletes legacy page-specific leadership blocks, keeping snippet-based blocks used elsewhere.
bedrock/mozorg/migrations/0043_delete_leadershippage.py Schema migration deleting the LeadershipPage model.
bedrock/mozorg/migrations/0044_delete_leadershippage_contentmodels.py Data migration intended to delete the stale django_content_type row for the removed model.

Comment on lines +7 to +18
STALE_MODELS = (
"LeadershipPage",
)


def remove_stale_contenttypes(apps, schema_editor):
# Migration 0043 dropped LeadershipPage
# but Django doesn't auto-purge the django_content_type rows for deleted models. Anything
# that resolves a log entry / permission via ContentType.get_object_for_this_type() (e.g.
# the Wagtail admin home recent-edits panel) then crashes because model_class() is None.
ContentType = apps.get_model("contenttypes", "ContentType")
ContentType.objects.filter(app_label="cms", model__in=STALE_MODELS).delete()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants