WT-1469: Add management commands for importing WordPress blog posts#1627
Draft
StuartMacKay wants to merge 2 commits into
Draft
WT-1469: Add management commands for importing WordPress blog posts#1627StuartMacKay wants to merge 2 commits into
StuartMacKay wants to merge 2 commits into
Conversation
Adds two management commands: 1. import_wordpress_blog_posts, which parses the WordPress export XML into BlogArticlePage entries (topics, tags, authors, images, and content blocks). 2. import_wordpress_redirects, which creates Redirect records from the CSV the import command produces. Also adds an Author snippet model with a BlogArticlePage.author field and ?author= filtering on the blog index, plus tests for all of the above.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
One-line summary
Import Wordpress blog posts, exported from blog.mozilla.org, into Wagtail CMS.
Significant changes and points to review
This pull request adds two management commands:
import_wordpress_blog_posts, which parses the WordPress export XML into BlogArticlePage entries (topics, tags, authors, images, and content blocks).
import_wordpress_redirects, which creates Redirect records from the CSV the import command produces.
Also adds an Author snippet model with a BlogArticlePage.author field and ?author= filtering on the blog index, plus tests for all of the above.
Issue / Bugzilla link
https://mozilla-hub.atlassian.net/browse/WT-1469
Testing
These two commands import the WordPress blog export into Wagtail. Test them locally against mozilla-blog-posts.xml.
IMPORTANT: If you want to test using Docker you will have to modify
Dockerfileto copy the xml file so the management commands can access it. Insert the follwing starting at line 107Import the blog posts
Confirms the file parses cleanly and shows what would be imported, without writing anything.
Runs the import for real. Look for a final summary line like:
Any failures are logged per-post to stderr and don't stop the rest of the import.
Verify in the Wagtail admin:
Re-run to check idempotency:
Should report 0 imported, 68 skipped, 0 failed — no duplicate pages created.
Create redirects from the old WordPress URLs
The first command writes wordpress_redirects.csv (old permalink → new page). Use it to create Wagtail redirects:
Shows what redirects would be created.
Creates the redirects for real.
Verify in the Wagtail admin: