enterprise.filters package#
Submodules#
enterprise.filters.accounts module#
Pipeline step for determining read-only account settings fields.
- class enterprise.filters.accounts.AccountSettingsEnterpriseReadOnlyFieldsStep(filter_type, running_pipeline, **extra_config)#
Bases:
PipelineStepAdds SSO-managed fields to the read-only account settings fields set.
This step is intended to be registered as a pipeline step for the
org.openedx.learning.account.settings.read_only_fields.requested.v1filter.When a user is linked to an enterprise customer whose SSO identity provider has
sync_learner_profile_dataenabled, the fields listed insettings.ENTERPRISE_READONLY_ACCOUNT_FIELDSare added toreadonly_fields. The"name"field is only added when the user has an existingUserSocialAuthrecord for the enterprise IdP backend.- run_filter(readonly_fields, user)#
Add enterprise SSO-managed fields to the read-only fields set.
The original code migrated from openedx-platform can be distilled into 3 logical branches:
If NO identify provider (IdP) has sync enabled → no readonly fields added.
If one or more IdPs have sync enabled, AND user has social auth → append ALL readonly fields.
If one or more IdPs have sync enabled, AND user has NO social auth → append readonly fields MINUS ‘name’.
Each return statement below is marked with the corresponding branch number.
enterprise.filters.course_modes module#
Pipeline steps for the course mode price filter.
- class enterprise.filters.course_modes.CalculateEnterpriseDiscountedPrice(filter_type, running_pipeline, **extra_config)#
Bases:
PipelineStepApply the enterprise-negotiated discount to a course mode’s price, if one applies.
If the current request is associated with an enterprise customer and the course mode has a SKU, this step overrides the price with the result of get_course_final_price. Otherwise the price passes through unchanged.
enterprise.filters.courseware module#
Pipeline steps for courseware-related openedx-filters contributed by the Enterprise app.
- class enterprise.filters.courseware.ActiveEnterpriseCheckStep(filter_type, running_pipeline, **extra_config)#
Bases:
PipelineStepDeny access when the learner’s active EnterpriseCustomer differs from the EnterpriseCustomer attached to their EnterpriseCourseEnrollment for this course.
Registered against
org.openedx.learning.courseware.access_checks.requested.v1. RaisesCoursewareAccessChecksRequested.PreventCoursewareAccessto deny access.- run_filter(user: Any, course_key: CourseKey) dict#
Abstract pipeline step runner.
Used to implement custom code that’ll be executed by OpenEdxPublicFilter’s pipeline runner. It must be implemented by child classes.
The signature is intentionally declared in its most permissive (gradual) form so that subclasses may narrow the accepted keyword arguments to those of the filter they implement without static type checkers reporting an incompatible override.
By design, the pipeline expects either of three (3) types of returns:
A dictionary with the arguments the method received. They can be modified in the process.
None. Returning this will stop the pipeline execution. The accumulated output until this moment will be returned.
An object different from a dict. Returning this will stop the pipeline execution. The accumulated output until this moment will be returned.
- class enterprise.filters.courseware.EnterpriseStartDateAccessFailureStep(filter_type, running_pipeline, **extra_config)#
Bases:
PipelineStepSubstitutes a more specific start-date access-error payload for enterprise learners.
Registered against
org.openedx.learning.course.start_date.validation_failed.v1. RaisesCourseStartDateValidationFailed.OverrideStartDateErrorwhen the request user is an enterprise learner enrolled via a subsidy for the given course. If the user is not an enterprise learner, the step is a no-op.- run_filter(course_key: CourseKey, start_date: datetime) dict#
Abstract pipeline step runner.
Used to implement custom code that’ll be executed by OpenEdxPublicFilter’s pipeline runner. It must be implemented by child classes.
The signature is intentionally declared in its most permissive (gradual) form so that subclasses may narrow the accepted keyword arguments to those of the filter they implement without static type checkers reporting an incompatible override.
By design, the pipeline expects either of three (3) types of returns:
A dictionary with the arguments the method received. They can be modified in the process.
None. Returning this will stop the pipeline execution. The accumulated output until this moment will be returned.
An object different from a dict. Returning this will stop the pipeline execution. The accumulated output until this moment will be returned.
enterprise.filters.dashboard module#
Pipeline steps for the student dashboard filter.
- class enterprise.filters.dashboard.DashboardContextEnricher(filter_type, running_pipeline, **extra_config)#
Bases:
PipelineStepEnrich the student dashboard context with enterprise-specific data.
Injects: enterprise_message, is_enterprise_user, and enterprise learner portal context keys.
enterprise.filters.discounts module#
Pipeline step for excluding certain learners from course discounts.
- class enterprise.filters.discounts.DiscountEligibilityEnterpriseStep(filter_type, running_pipeline, **extra_config)#
Bases:
PipelineStepMarks learners linked to an enterprise as ineligible for LMS-controlled discounts.
This step is intended to be registered as a pipeline step for the
org.openedx.learning.discount.eligibility.check.requested.v1filter.LMS-controlled discounts (such as the first-purchase offer) are not applicable to learners whose enrollment is managed by an enterprise. This step queries the enterprise learner status and, if the user qualifies, raises
DiscountIneligibleto halt the pipeline and prevent the discount from being applied.- run_filter(user: AbstractBaseUser, course_key: CourseKey) dict#
Raise
DiscountIneligibleif the user is an enterprise learner.- Parameters:
user (User) – the Django User being checked for discount eligibility.
course_key – identifies the course (passed through unchanged).
- Returns:
updated pipeline data (unchanged) when the user is not an enterprise learner.
- Return type:
- Raises:
DiscountEligibilityCheckRequested.DiscountIneligible – when the user is linked
to an enterprise, halting further pipeline processing. –
enterprise.filters.grades module#
Pipeline step for enriching grade analytics event context.
- class enterprise.filters.grades.GradeEventContextEnricher(filter_type, running_pipeline, **extra_config)#
Bases:
PipelineStepEnriches a grade analytics event context dict with the learner’s enterprise UUID.
This step is intended to be registered as a pipeline step for the
org.openedx.learning.grade.context.requested.v1filter.If the user is enrolled in the given course through an enterprise, the enterprise UUID is added to the context under the key
"enterprise_uuid". If the user has no enterprise course enrollment, the context is returned unchanged.- run_filter(context: dict, user_id: int, course_id: str) dict[str, Any]#
Add enterprise UUID to the event context if the user has an enterprise enrollment.
- Parameters:
- Returns:
updated pipeline data with the enriched
contextdict:{ "context": <enriched context>, "user_id": <unchanged>, "course_id": <unchanged>, }
- Return type:
enterprise.filters.logistration module#
Pipeline steps for the logistration (login/registration) filters.
- class enterprise.filters.logistration.ActivationEmailEnterpriseContextEnricher(filter_type, running_pipeline, **extra_config)#
Bases:
PipelineStepAdds
is_enterprise_learnerto the activation email’s message context.This step is intended to be registered as a pipeline step for the
org.openedx.authentication.account_activation.email.context.generated.v1filter.
- class enterprise.filters.logistration.AuthnMFEEnterpriseContextEnricher(filter_type, running_pipeline, **extra_config)#
Bases:
PipelineStepEnrich the authentication MFE context with enterprise branding.
This step is the authentication MFE counterpart to LogistrationViewEnterpriseContextEnricher. The MFE serves a flat context (as opposed to the legacy combined login/registration page’s nested
context['data']shape), so this step only adds theenterpriseBrandingpayload consumed by the authentication MFE, looked up from the enterprise customer associated with the current SSO session (Nonewhen there is no enterprise customer).The payload goes into
extra_contextrather thancontext: the platform’s MFE context serializer declares noenterpriseBrandingfield, and drops undeclaredcontextentries. Entries inextra_contextare merged into the served response as-is, so this step owns the shape of its own payload.
- class enterprise.filters.logistration.LoginFormEnterpriseOverrides(filter_type, running_pipeline, **extra_config)#
Bases:
PipelineStepOverride login form description fields for enterprise SSO users.
The filter fires for every login form build, and passes the third-party auth state of the request. When the running pipeline’s provider is known and the request is associated with an enterprise customer, the email field is pre-filled from the provider details and made read-only. Otherwise it is a no-op.
- class enterprise.filters.logistration.LogistrationViewEnterpriseContextEnricher(filter_type, running_pipeline, **extra_config)#
Bases:
PipelineStepEnrich the logistration page context with enterprise customer data.
This step calls enterprise_customer_for_request to identify the enterprise customer associated with the current SSO session, then delegates to the enterprise_support utilities to update the context with enterprise-specific sidebar content and third-party-auth adjustments. It also injects the enterprise slug login URL and the enterprise-enabled flag consumed by the logistration page’s JS.
- class enterprise.filters.logistration.LogistrationViewEnterpriseCookieSetter(filter_type, running_pipeline, **extra_config)#
Bases:
PipelineStepSet or delete enterprise cookies on the rendered logistration response.
This step runs on every logistration page render (not only for enterprise customers), mirroring the original platform behavior: it sets the
experiments_is_enterprisecookie fromcontext['enable_enterprise_sidebar']and deletes the enterprise customer cookie so that subsequent requests show the default login page.
- class enterprise.filters.logistration.PostLoginEnterpriseRedirect(filter_type, running_pipeline, **extra_config)#
Bases:
PipelineStepUpdates redirect url to enterprise selection page if user is associated with multiple enterprises otherwise return the next url.
- class enterprise.filters.logistration.RegistrationFormEnterpriseOverrides(filter_type, running_pipeline, **extra_config)#
Bases:
PipelineStepOverride registration form description fields for enterprise SSO users.
The filter fires for every registration form build, and passes the third-party auth state of the request. When the running pipeline’s provider is configured to skip the registration form and we are in an enterprise context, we need to hide all fields except for terms of service and ensure that the user explicitly checks that field. Otherwise it is a no-op.
The platform iterates its known registration fields and skips any without a provider override; this step iterates the provider overrides directly, which is equivalent because providers only return values for standard registration fields.
enterprise.filters.support module#
Pipeline steps for the support views filters.
- class enterprise.filters.support.SupportContactEnterpriseTagStep(filter_type, running_pipeline, **extra_config)#
Bases:
PipelineStepAppend a support-ticket tag for linked customer-account requests.
This step is intended to be registered as a pipeline step for the
org.openedx.learning.support.contact.context.requested.v1filter.- run_filter(context)#
Append ‘enterprise_learner’ to context[‘tags’] if the requester is linked to a customer account.
- class enterprise.filters.support.SupportEnterpriseEnrollmentDataInjector(filter_type, running_pipeline, **extra_config)#
Bases:
PipelineStepInject enterprise course enrollment data into the support enrollment view.
Attaches enterprise course enrollment records (with data-sharing consent records) to each matching enrollment dict via a new enterprise_course_enrollments key.
This step is intended to be registered as a pipeline step for the
org.openedx.learning.support.enrollment.data.requested.v1filter.
Module contents#
Filter pipeline step implementations for edx-enterprise openedx-filters integrations.