Repository navigation
Conversation
OpenAPI ChangesNo changes detected Unexpected changes? Ensure your branch is up-to-date with |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The ETL refresh can undo manual revocations and re-expose letters when the warehouse lacks revoked, while the display page renders an empty letter instead of handling API 404 responses.
2 open issues
What changed in this PR
Adds revocation support to program certificates so MIT Learn can hide revoked certificates and block access to their letters while preserving links for later reinstatement.
Changes:
- Adds a
revokedfield, migration, and warehouse import mapping. - Filters revoked certificates from listings, letter retrieval, and redirects without exposing the flag in API responses.
- Adds tests for revocation, reinstatement, and preservation of existing letters.
| File | Description |
|---|---|
profiles/views.py |
Filters revoked certificates from certificate and letter endpoints. |
profiles/views_test.py |
Tests revoked access restrictions and letter reinstatement. |
profiles/serializers.py |
Excludes the revocation flag from serialized certificates. |
profiles/models.py |
Adds revocation state and a valid-certificate query helper. |
profiles/migrations/0040_programcertificate_revoked.py |
Adds the database field with a false default. |
profiles/etl.py |
Maps warehouse revocation data into certificate updates. |
profiles/etl_test.py |
Tests revocation mapping and in-place updates that preserve letters. |
Review effort: Balanced
Contributor
Author
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?
Closes https://github.com/mitodl/hq/issues/14133
Description (What does it do?)
This PR ensures we have a "is_revoked" flag for program certificates which gets used to determine if a program letter is available to user in learn
How can this be tested?
docker compose run --rm web python manage.py migratedocker compose run --rm web python manage.py seed_program_letter --email you@example.com --micromasters-program-id 1 --mitxonline-program-id <program id you're enrolled in>http://api.open.odl.local:8065/api/v0/program_certificates/http://open.odl.local:8062/program_letter/<uuid>/view-> visiting it should render a letter as expected.docker compose run --rm web python manage.py shell -c "from profiles.models import ProgramCertificate, ProgramLetter; print(ProgramCertificate.objects.filter(user_email='you@example.com').update(is_revoked=True), ProgramLetter.objects.count())"Additional Context
This will be followed up with a data platform change to actually sync the new field