enterprise.filters package

Contents

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: PipelineStep

Adds 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.v1 filter.

When a user is linked to an enterprise customer whose SSO identity provider has sync_learner_profile_data enabled, the fields listed in settings.ENTERPRISE_READONLY_ACCOUNT_FIELDS are added to readonly_fields. The "name" field is only added when the user has an existing UserSocialAuth record 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:

  1. If NO identify provider (IdP) has sync enabled → no readonly fields added.

  2. If one or more IdPs have sync enabled, AND user has social auth → append ALL readonly fields.

  3. 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.

Parameters:
  • readonly_fields (set) – current set of read-only account field names.

  • user (User) – the Django User whose account settings are being updated.

Returns:

updated pipeline data with readonly_fields key.

Return type:

dict

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: PipelineStep

Apply 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.

run_filter(user: Any, course_mode_data: Any, price: int) → dict[str, Any]#

Override price with the enterprise-discounted price, if applicable.

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: PipelineStep

Deny 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. Raises CoursewareAccessChecksRequested.PreventCoursewareAccess to 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:

  1. A dictionary with the arguments the method received. They can be modified in the process.

  2. None. Returning this will stop the pipeline execution. The accumulated output until this moment will be returned.

  3. 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: PipelineStep

Substitutes a more specific start-date access-error payload for enterprise learners.

Registered against org.openedx.learning.course.start_date.validation_failed.v1. Raises CourseStartDateValidationFailed.OverrideStartDateError when 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:

  1. A dictionary with the arguments the method received. They can be modified in the process.

  2. None. Returning this will stop the pipeline execution. The accumulated output until this moment will be returned.

  3. 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: PipelineStep

Enrich the student dashboard context with enterprise-specific data.

Injects: enterprise_message, is_enterprise_user, and enterprise learner portal context keys.

run_filter(context: dict[str, Any], template_name: str) → dict[str, Any]#

Inject enterprise data into the dashboard context.

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: PipelineStep

Marks 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.v1 filter.

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 DiscountIneligible to halt the pipeline and prevent the discount from being applied.

run_filter(user: AbstractBaseUser, course_key: CourseKey) → dict#

Raise DiscountIneligible if 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:

dict

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: PipelineStep

Enriches 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.v1 filter.

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:
  • context (dict) – the event tracking context dict.

  • user_id (int) – the ID of the user whose grade event is being emitted.

  • course_id (str) – the course key for the grade event.

Returns:

updated pipeline data with the enriched context dict:

{
    "context": <enriched context>,
    "user_id": <unchanged>,
    "course_id": <unchanged>,
}

Return type:

dict

enterprise.filters.logistration module#

Pipeline steps for the logistration (login/registration) filters.

class enterprise.filters.logistration.ActivationEmailEnterpriseContextEnricher(filter_type, running_pipeline, **extra_config)#

Bases: PipelineStep

Adds is_enterprise_learner to 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.v1 filter.

run_filter(user: Any, message_context: dict[str, Any]) → dict[str, Any]#

Add the enterprise learner flag to the activation email message context.

Parameters:
  • user (User) – the Django User the activation email is being composed for.

  • message_context (dict) – context dictionary used to render the activation email.

Returns:

updated pipeline data with user and message_context keys.

Return type:

dict

class enterprise.filters.logistration.AuthnMFEEnterpriseContextEnricher(filter_type, running_pipeline, **extra_config)#

Bases: PipelineStep

Enrich 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 the enterpriseBranding payload consumed by the authentication MFE, looked up from the enterprise customer associated with the current SSO session (None when there is no enterprise customer).

The payload goes into extra_context rather than context: the platform’s MFE context serializer declares no enterpriseBranding field, and drops undeclared context entries. Entries in extra_context are merged into the served response as-is, so this step owns the shape of its own payload.

run_filter(context: dict[str, Any], extra_context: dict[str, Any]) → dict[str, Any]#

Add enterprise branding to the authentication MFE context.

class enterprise.filters.logistration.LoginFormEnterpriseOverrides(filter_type, running_pipeline, **extra_config)#

Bases: PipelineStep

Override 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.

run_filter(form_desc: FormDescriptionProtocol, running_pipeline: RunningPipeline | None, current_provider: ProviderConfigProtocol | None) → dict[str, Any]#

Apply enterprise SSO overrides to the login form description.

class enterprise.filters.logistration.LogistrationViewEnterpriseContextEnricher(filter_type, running_pipeline, **extra_config)#

Bases: PipelineStep

Enrich 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.

run_filter(context: dict[str, Any]) → dict[str, Any]#

Enrich context with enterprise customer data.

class enterprise.filters.logistration.LogistrationViewEnterpriseCookieSetter(filter_type, running_pipeline, **extra_config)#

Bases: PipelineStep

Set 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_enterprise cookie from context['enable_enterprise_sidebar'] and deletes the enterprise customer cookie so that subsequent requests show the default login page.

run_filter(response: Any, context: dict[str, Any]) → dict[str, Any]#

Apply enterprise cookie handling to the logistration response.

class enterprise.filters.logistration.PostLoginEnterpriseRedirect(filter_type, running_pipeline, **extra_config)#

Bases: PipelineStep

Updates redirect url to enterprise selection page if user is associated with multiple enterprises otherwise return the next url.

run_filter(redirect_url: str, user: Any) → dict[str, Any]#

Return enterprise selection page URL if user is associated with multiple enterprises.

class enterprise.filters.logistration.RegistrationFormEnterpriseOverrides(filter_type, running_pipeline, **extra_config)#

Bases: PipelineStep

Override 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.

run_filter(form_desc: FormDescriptionProtocol, running_pipeline: RunningPipeline | None, current_provider: ProviderConfigProtocol | None) → dict[str, Any]#

Hide provider-prefilled registration fields (except terms of service) for enterprise SSO registrations.

enterprise.filters.support module#

Pipeline steps for the support views filters.

class enterprise.filters.support.SupportContactEnterpriseTagStep(filter_type, running_pipeline, **extra_config)#

Bases: PipelineStep

Append 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.v1 filter.

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: PipelineStep

Inject 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.v1 filter.

run_filter(enrollments_data: list[dict], user: Any) → dict#

Attach enterprise course enrollment records to each matching enrollment dict in place.

Module contents#

Filter pipeline step implementations for edx-enterprise openedx-filters integrations.