Repository navigation
fix: keep course dates that a partial course_details PUT leaves out - #39328
newairforces wants to merge 2 commits into
Conversation
CourseDetails.update_from_json wrote None into start, end, enrollment
start/end and certificate_available_date whenever their key was missing
from the body. A partial PUT such as {"self_paced": true} therefore
cleared the course's start date, which made can_toggle_course_pacing
return False, so the pacing change was dropped while the view answered
200. A missing date key now leaves the stored value unchanged; an
explicit null or "" still clears it.
Fixes openedx#39094
Co-authored-by: Claude <claude@anthropic.com>
Adds a model test that a body without date keys keeps all four schedule dates (while an explicit None still clears one), and a view test with the request from openedx#39094: PUT {"self_paced": true} on a course that has not started yet switches it to self-paced and keeps its start date. Both fail without the previous commit. Co-authored-by: Claude <claude@anthropic.com>
|
Thanks for the pull request, @newairforces! 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:
🔘 Submit a signed contributor agreement (CLA)
If you've signed an agreement in the past, you may need to re-sign. Once you've signed the CLA, please allow 1 business day for it to be processed. 🔘 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. |
Description
PUT /api/contentstore/v1/course_details/<course_id>is documented as taking partial bodies, butCourseDetails.update_from_jsonwroteNoneinto every date field whose key was missing from the body:start,end,enrollment_start,enrollment_end, andcertificate_available_date. So{"self_paced": true}on a course that hasn't started:can_toggle_course_pacingreturnFalse,self_paced: false.This PR treats a missing date key as "leave it unchanged": each of the five
else: converted = Nonebranches now keeps the block's current value. An explicitnullor""still clears a date, so the authoring MFE, which always sends the whole form, behaves the same as before.User roles affected: Developer (anyone calling the course details API with a partial body). Course Author only indirectly: a partial PUT no longer erases their course dates.
What this PR does not change:
can_toggle_course_pacing. Whether it should answer 400 instead is the open question I asked on the issue, so I left it out of this PR.update_course_detailsincms/djangoapps/contentstore/utils.pystill resets the certificate display behavior even though pacing doesn't change. That goes with the 400 question.Supporting information
Fixes #39094
Claim and question on the issue: #39094 (comment)
I've signed the individual CLA, which @bmtcril asked for on the issue. This is my first Open edX PR, so CI will need a maintainer to start it.
Testing instructions
docker run -d -p 27017:27017 mongo:7), and install the testing group (make test-requirements).openedx/core/djangoapps/models/course_details.pyfrommasterand run steps 2 and 3 again.Both new tests on the unfixed
course_details.py:My local repro (a throwaway test through Django's test client against the real view, not part of this PR), on a course starting 2040-01-01 with end and enrollment dates set, sending
PUT {"self_paced": true}.Before (
master):After (this branch):
Checks I ran on this branch (macOS, Python 3.12, MongoDB 7, SQLite):
Not run locally: the full CI test shards and module-wide pylint. They need services and the dev requirements that I don't have set up, so I'm relying on CI for those.
Deadline
None.
Other information
null. Every caller in this repo passes the request body straight through, so the change only matters to clients that send partial bodies (the issue notes that the MFE sends the whole form):AI disclosure, per the Open edX AI policy: I used Claude (through Claude Code) to help trace the request from the view to
update_from_json, write the two tests and the local repro test, and draft this description. I picked the fix, ran every command above on my own machine, and checked the output against the code. The commits carry aCo-authored-by: Claudetrailer.