WIP: Add backfill_program_certificate_titles management command#3697
Open
zamanafzal wants to merge 3 commits into
Open
WIP: Add backfill_program_certificate_titles management command#3697zamanafzal wants to merge 3 commits into
zamanafzal wants to merge 3 commits into
Conversation
Issued program certificates freeze their "Certificate Title" (product_name) into the CMS page revision in effect at issue time, so editing the live title later does not update already-issued certs. This one-time backfill rewrites each issued program certificate's frozen product_name to the live CMS page value. Safety: dry-run by default (--commit to write), requires exactly one of --program/--all-programs, skips programs whose live title is empty or still a "PLACEHOLDER - " default, is idempotent, edits each shared revision once, and never touches null-revision (revoked) certs. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
OpenAPI ChangesShow/hide ## Changes for v0.yaml:Unexpected changes? Ensure your branch is up-to-date with |
Address Sentry review feedback: reassign the JSONField value and save with update_fields=["content"] instead of mutating revision.content in place, so the write is robust to any save()/dirty-tracking behavior and only touches the content column (no incidental field updates). Behavior is unchanged; all 14 command tests still pass. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Restructure the command's output so each targeted program prints a full block (readable_id, program title, current frozen title, target live title, and a YES/NO/SKIPPED change flag). Already-correct and skipped programs now appear too, so nothing falls through silently. This lets the dry-run be shared directly with admins to verify titles before --commit. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
What are the relevant tickets?
https://github.com/mitodl/hq/issues/11938
Description
Issued program certificates freeze their "Certificate Title" (
product_name) into the Wagtail page revision in effect at issue time (ProgramCertificate.certificate_page_revision), and the display path readscertificate_page_revision.as_object().product_name. So editing the live "Certificate Title" in the CMS does not update certificates already issued — they keep their old frozen title until a one-time backfill is run.This adds a
backfill_program_certificate_titlesmanagement command (workstream 1 of hq#11938, follow-up to hq#11907 / #3695) that rewrites each issued program certificate's frozenproduct_nameto the live CMS page value.Behavior & safety
--commitis required to write.--program(repeatable) /--all-programs; neither or both raisesCommandError, so a bare run touches nothing."PLACEHOLDER - "default; placeholder text is never stamped onto real certificates.[skipped]; a second--commitrun is a no-op.Revisionrow, so each shared revision is edited once (report shows(N certs)).transaction.atomic(); a finalSummary:line tallies programs processed/skipped, revisions changed, and certs affected.Write strategy
Edits the existing
Revision.content["product_name"]in place (per design): simplest, fewest writes, fixes all certs sharing a revision at once. Trade-off — the page's revision-history view will retroactively show the corrected title, which is acceptable for a one-time correction.Test plan
--commitrewrites frozenproduct_nameto the live title (asserted via the display pathrevision.as_object().product_name)--commitreports zero changesCommandError; both flags →CommandError--all-programsprocesses clean programs and skips placeholder / page-less ones--programreadable_id reported and skipped; other programs still processedruff format+ruff checkclean