feat: add CourseModeCheckoutStarted filter#338
Conversation
| dict: the (possibly enriched) checkout context. | ||
| """ | ||
| data = super().run_pipeline(context=context, request=request, course_mode=course_mode) | ||
| return data.get("context") |
There was a problem hiding this comment.
It's unconventional for the return signature to differ from the arguments signature. Better would be:
| return data.get("context") | |
| return data.get("context"), data.get("request"), data.get("course_mode") |
There was a problem hiding this comment.
Pull request overview
This PR introduces a new public filter in the learning subdomain to allow plugins to enrich the checkout context when a user selects a course mode and the checkout flow begins (ENT-11573).
Changes:
- Add
CourseModeCheckoutStartedfilter (org.openedx.learning.course_mode.checkout.started.v1) with arun_filter(context, request, course_mode)entrypoint. - Add a unit test validating default pass-through behavior when no pipeline steps are configured.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| openedx_filters/learning/filters.py | Adds the CourseModeCheckoutStarted filter class and metadata docstring. |
| openedx_filters/learning/tests/test_filters.py | Adds a basic test ensuring the new filter returns the context unchanged by default. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| class CourseModeCheckoutStarted(OpenEdxPublicFilter): |
| org.openedx.learning.course_mode.checkout.started.v1 | ||
|
|
||
| Trigger: | ||
| - Repository: openedx/edx-platform |
dc609c4 to
7d08707
Compare
fa58795 to
f1c3ccc
Compare
ca1db1b to
e911956
Compare
59ad3eb to
8912b79
Compare
|
Here's a version I'd approve quickly (after adding docstrings, unit tests, and conducting integration tests): from typing import Any, Optional, Protocol
class CourseModePriceRequested(OpenEdxPublicFilter):
filter_type = "org.openedx.learning.course_mode.price.requested.v1"
@classmethod
def run_filter(cls, user: Any, course_mode_data: Any, price: float) -> tuple[Any, Any, float]:
data = super().run_pipeline(user=user, course_mode_data=course_mode_data, price=price)
return data["user"], data["course_mode_data"], data["price"]
|
|
Closing to remind you that you need to re-open this PR from your own openedx-filters branch so that I can approve it. |
ENT-11573
Related: