feat: replace enterprise_support import with DiscountEligibilityCheckRequested filter#349
Open
marlonkeating wants to merge 2 commits into
Open
feat: replace enterprise_support import with DiscountEligibilityCheckRequested filter#349marlonkeating wants to merge 2 commits into
marlonkeating wants to merge 2 commits into
Conversation
…Requested filter Removes direct lazy imports of is_enterprise_learner from openedx.features.enterprise_support.utils in applicability.py and replaces them with calls to the DiscountEligibilityCheckRequested openedx-filter. Adds the filter to OPEN_EDX_FILTERS_CONFIG with the DiscountEligibilityStep pipeline step. Updates tests to mock the filter instead of using enterprise model factories. ENT-11564 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR replaces the direct enterprise eligibility check in the discounts applicability logic with the DiscountEligibilityCheckRequested openedx-filters pipeline, and updates LMS settings/tests to support the new filter-driven behavior.
Changes:
- Switch discount eligibility gating (
can_receive_discount,can_show_streak_discount_coupon) fromenterprise_supporttoDiscountEligibilityCheckRequested.run_filter(...). - Update discount applicability tests to patch the new filter and validate ineligibility behavior.
- Introduce an
OPEN_EDX_FILTERS_CONFIGdefault entry wiring the discount eligibility filter to an enterprise pipeline step.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| openedx/features/discounts/applicability.py | Replaces enterprise-specific logic with a filter hook to allow pluggable eligibility decisions. |
| openedx/features/discounts/tests/test_applicability.py | Updates tests to patch/drive the new filter-based eligibility behavior. |
| lms/envs/common.py | Adds default openedx-filters configuration for the discount eligibility filter. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| from datetime import datetime, timedelta | ||
| from unittest.mock import Mock, patch | ||
| from zoneinfo import ZoneInfo |
Comment on lines
+3819
to
+3824
| # .. setting_name: OPEN_EDX_FILTERS_CONFIG | ||
| # .. setting_default: {} | ||
| # .. setting_description: Configuration dict for openedx-filters pipeline steps. | ||
| # Keys are filter type strings; values are dicts with 'fail_silently' (bool) and | ||
| # 'pipeline' (list of dotted-path strings to PipelineStep subclasses). | ||
| OPEN_EDX_FILTERS_CONFIG = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
release-ulmocompanion PR of openedx#38099Description
Describe what this pull request changes, and why. Include implications for people using this change.
Design decisions and their rationales should be documented in the repo (docstring / ADR), per
OEP-19, and can be
linked here.
Useful information to include:
"Developer", and "Operator".
changes.
Supporting information
Link to other information about the change, such as Jira issues, GitHub issues, or Discourse discussions.
Be sure to check they are publicly readable, or if not, repeat the information here.
Testing instructions
Please provide detailed step-by-step instructions for testing this change.
Deadline
"None" if there's no rush, or provide a specific date or event (and reason) if there is one.
Other information
Include anything else that will help reviewers and consumers understand the change.