Wgu jesse stewart/instructor dashboard certificates bulk#38464
Wgu jesse stewart/instructor dashboard certificates bulk#38464wgu-jesse-stewart wants to merge 27 commits intoopenedx:masterfrom
Conversation
- Add ToggleCertificateGenerationView endpoint to enable/disable certificate generation - Add CertificateExceptionsView endpoint to grant and remove certificate exceptions (allowlist) - Add CertificateInvalidationsView endpoint to invalidate and re-validate certificates - Update certificate status labels to be more user-friendly (e.g., "Received" instead of "already received") - Update certificate generation history labels (e.g., "All Learners" instead of "All learners") - Add invalidation notes to IssuedCertificateSerializer - Add certificatesEnabled flag to CourseInformationSerializerV2
… of https://github.com/WGU-Open-edX/edx-platform into wgu-jesse-stewart/instructor_dashboard_certificates_v2
|
Thanks for the pull request, @wgu-jesse-stewart! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
feat: add bulk certificate exceptions endpoint and stabilize JWT tests
Description
Adds a new v2 instructor API endpoint for granting certificate exceptions in bulk via CSV upload, and refactors the JWT test module to avoid a stale-timestamp issue.
New endpoint:
BulkCertificateExceptionsViewPOST /api/instructor/v2/courses/{course_id}/certificates/exceptions/bulkAccepts a multipart form upload with a
filefield containing a CSV. Each row isusername_or_email[,notes]. The view:*.csv.utf-8-sigso Excel-exported files with a BOM work without the user having to think about it._resolve_learners_to_usersand validates them via_validate_learners_for_certificate_exceptionsbefore any writes — same helpers used by the single-learner path, so behavior stays consistent.certs_api.create_or_update_certificate_allowlist_entryfor each valid learner and aggregates results into a single{ "success": [...], "errors": [...] }payload.Errors during a single row are caught and reported in
errorsrather than aborting the batch — partial success is the expected mode for CSV imports.Permission checks reuse
permissions.InstructorPermissionandCERTIFICATE_EXCEPTION_VIEW, matching the existing single-exception endpoint.Test stabilization:
test_jwt.pyThe module previously computed
test_now = int(time())once at import and reused it across every test, along with a module-levelexpected_full_tokendict built from that timestamp. That makes the suite sensitive to import-vs-execution timing and to test reordering — and means any test that mutatesexpected_full_tokenwould leak into others.Replaced both module-level constants with two helpers:
get_test_now()— returns the current time when the test runs.get_expected_full_token(test_now)— returns a fresh expected payload bound to that timestamp.Each test now grabs its own
test_nowat the top and builds its expected payload from it. No behavior change to the JWT code itself.User roles impacted
Supporting information
_resolve_learners_to_users/_validate_learners_for_certificate_exceptionshelpers introduced earlier in the v2 redesign.Testing instructions
Bulk certificate exceptions endpoint
exceptions.csv):200withsuccesscontaining the two valid learners anderrorscontaining the unknown email with a clear message.400:filefield in the request..csvextension.403.Certificate exception granted ...info line per successful row, naming the acting instructor.JWT tests
Run the affected module:
All tests should pass. Optionally re-run several times in a row, or with
-p no:randomlyreversed (random order), to confirm there's no ordering sensitivity.Deadline
None.
Other information
BulkCertificateExceptionsViewfollows the same broad-except pattern as neighboring views inapi_v2.py(withpylint: disable=broad-except) so per-row failures don't abort the batch. Each caught exception is logged vialog.exceptionwith the user and course key.uploaded_file.read()); for very large rosters this may want a streamed parser later, but matches the existing bulk-CSV endpoints in this module.