-
Notifications
You must be signed in to change notification settings - Fork 4.2k
feat: added update mode price api for instructors #37613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: ahtisham/add_course_modes_apis
Are you sure you want to change the base?
feat: added update mode price api for instructors #37613
Conversation
34201ee to
6d0bf82
Compare
fix: resolved linter errors chore: added docs to api feat: added update mode price api for instructors fix: resolved linter errors fix: resolved linter errors fix: removed redundant code
95fdf39 to
43cc724
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a new API endpoint for updating the price of a specific course enrollment mode via PATCH request. The endpoint allows instructors and staff to modify course mode pricing dynamically.
- Introduces
CourseModePriceViewAPI view with PATCH method for updating mode prices - Adds
ModePriceUpdateSerializerto validate price update requests - Enhances
InstructorPermissionto include GlobalStaff user support - Adds comprehensive test coverage for authentication, authorization, and validation scenarios
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| lms/djangoapps/instructor/views/serializer.py | Adds ModePriceUpdateSerializer to validate price field in update requests |
| lms/djangoapps/instructor/views/api_urls.py | Registers new course_mode_price URL pattern for the price update endpoint |
| lms/djangoapps/instructor/views/api.py | Implements CourseModePriceView with PATCH method and adds import; includes minor typo fix in unrelated docstring |
| lms/djangoapps/instructor/tests/test_api.py | Adds TestCourseModePriceView test suite covering success, permission, validation, and error cases |
| lms/djangoapps/instructor/permissions.py | Extends InstructorPermission.has_permission to grant access to GlobalStaff users |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
Description
Issue: #37465
This PR adds a new PATCH API endpoint to allow an instructor to update the price for a specific course enrollment mode (e.g., verified).
PATCH /api/instructor/v1/courses/{course_key}/modes/{mode_slug}/price
This endpoint requires InstructorPermission (is_staff) and expects the Content-Type header to be application/merge-patch+json. The price should be sent as an integer in the smallest currency unit (e.g., cents).
Example Request
Success Response
The endpoint returns an empty body with a 204 No Content status upon a successful price update.
Error Responses
Testing