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

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.

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

Module contents#

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