Skip to content

feat: add CourseModeCheckoutStarted filter#338

Closed
pwnage101 wants to merge 2 commits into
openedx:mainfrom
pwnage101:pwnage101/ENT-11573
Closed

feat: add CourseModeCheckoutStarted filter#338
pwnage101 wants to merge 2 commits into
openedx:mainfrom
pwnage101:pwnage101/ENT-11573

Conversation

@pwnage101

@pwnage101 pwnage101 commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

Comment thread openedx_filters/learning/filters.py Outdated
dict: the (possibly enriched) checkout context.
"""
data = super().run_pipeline(context=context, request=request, course_mode=course_mode)
return data.get("context")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's unconventional for the return signature to differ from the arguments signature. Better would be:

Suggested change
return data.get("context")
return data.get("context"), data.get("request"), data.get("course_mode")

Copilot AI left a comment

Copy link
Copy Markdown

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 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 CourseModeCheckoutStarted filter (org.openedx.learning.course_mode.checkout.started.v1) with a run_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.

Comment on lines +1785 to +1786

class CourseModeCheckoutStarted(OpenEdxPublicFilter):
Comment thread openedx_filters/learning/filters.py Outdated
org.openedx.learning.course_mode.checkout.started.v1

Trigger:
- Repository: openedx/edx-platform
@kiram15
kiram15 force-pushed the pwnage101/ENT-11573 branch from ca1db1b to e911956 Compare June 29, 2026 21:03
@kiram15
kiram15 force-pushed the pwnage101/ENT-11573 branch from 59ad3eb to 8912b79 Compare June 29, 2026 21:10

@pwnage101 pwnage101 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pwnage101

pwnage101 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

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"]

course_mode_data would be passed a Mode NamedTuple, and price would be the full, non-discounted price.

@pwnage101

Copy link
Copy Markdown
Contributor Author

Closing to remind you that you need to re-open this PR from your own openedx-filters branch so that I can approve it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants