Pipeline Steps#

This is the list of pipeline steps that are available in the pipeline.py file.

Filters steps illustrating how to modify the application behavior by using pipeline steps.

Pipeline steps are used to modify the behavior of the application by altering the input data or stopping the process. The pipeline steps are executed in the order they are defined in the configuration OPEN_EDX_FILTERS_CONFIG for each filter type.

This file contains examples of pipeline steps that modify the behavior of the application, such as stopping the enrollment process, modifying the user’s profile, or changing the certificate mode before rendering.

These use cases are illustrative and can be adapted to your specific needs.

class openedx_filters_samples.pipeline.ModifyCertificateModeBeforeCreation(filter_type, running_pipeline, **extra_config)#

Change certificate mode from ‘honor’ to ‘no-id-professional’ before certificate creation.

Example usage:

>>> OPEN_EDX_FILTERS_CONFIG = {
        "org.openedx.learning.certificate.creation.requested.v1": {
            "fail_silently": False,
            "pipeline": [
                "openedx_filters_samples.pipeline.ModifyCertificateModeBeforeCreation"
            ]
        }
    }
run_filter(user, course_key, mode, status, *args, **kwargs)#

Change the certificate mode from ‘honor’ to ‘no-id-professional’ before certificate creation.

Parameters:
  • user (User) – The user requesting the certificate.

  • course_key (CourseKey) – The course key for the course.

  • mode (str) – The mode of the certificate.

  • status (str) – The status of the certificate.

class openedx_filters_samples.pipeline.ModifyContextBeforeRender(filter_type, running_pipeline, **extra_config)#

Modify template context before rendering the certificate.

By modifying the context before rendering the certificate, now the context will have a context_modified field that can be used in the template to check if the context was modified.

Example usage:

>>> OPEN_EDX_FILTERS_CONFIG = {
        "org.openedx.learning.certificate.render.started.v1": {
            "fail_silently": False,
            "pipeline": [
                "openedx_filters_samples.pipeline.ModifyContextBeforeRender"
            ]
        }
    }
run_filter(context, *args, **kwargs)#

Modify the context before rendering the certificate.

Parameters:

context (dict) – The context data for the certificate

class openedx_filters_samples.pipeline.ModifyModeBeforeEnrollment(filter_type, running_pipeline, **extra_config)#

Change enrollment mode to ‘honor’ before enrollment in all cases.

Example usage:

>>> OPEN_EDX_FILTERS_CONFIG = {
    "org.openedx.learning.course.enrollment.started.v1": {
        "fail_silently": False,
        "pipeline": [
            "openedx_filters_samples.pipeline.ModifyModeBeforeEnrollment"
        ]
    }
}
run_filter(user, course_key, mode, *args, **kwargs)#

Change the enrollment mode to ‘honor’ before enrollment.

Parameters:
  • user (User) – The user enrolling in the course.

  • course_key (CourseKey) – The course key for the course.

  • mode (str) – The mode of the enrollment.

class openedx_filters_samples.pipeline.ModifyUserProfileBeforeCohortChange(filter_type, running_pipeline, **extra_config)#

Add cohort_info field to the user’s profile before cohort change.

By modifying the user’s profile before cohort change, now the user’s profile will have a cohort_info field with the value of the course user group from which the user is changing cohorts or being assigned to a cohort.

Example usage:

>>> OPEN_EDX_FILTERS_CONFIG = {
        "org.openedx.learning.cohort.change.requested.v1": {
            "fail_silently": False,
            "pipeline": [
                "openedx_filters_samples.pipeline.ModifyUserProfileBeforeCohortChange"
            ]
        }
    }
run_filter(current_membership, target_cohort, *args, **kwargs)#

Modify the user’s profile before cohort change or assignment.

Parameters:
  • current_membership (CourseUserGroupMembership) – The current membership of the user.

  • target_cohort (CourseUserGroup) – The target cohort to which the user is changing cohorts or being assigned.

class openedx_filters_samples.pipeline.ModifyUserProfileBeforeLogin(filter_type, running_pipeline, **extra_config)#

Add last_login field to the user’s profile before login.

By modifying the user’s profile before login, now the user’s profile will have a last_login field with the value of the user’s last login.

Example usage:

>>> OPEN_EDX_FILTERS_CONFIG = {
    "org.openedx.learning.student.login.requested.v1": {
        "fail_silently": False,
        "pipeline": [
            "openedx_filters_samples.pipeline.ModifyUserProfileBeforeLogin"
        ]
    }
}
run_filter(user, *args, **kwargs)#

Modify the user’s profile before login.

Parameters:

user (User) – The user logging in.

class openedx_filters_samples.pipeline.ModifyUserProfileBeforeUnenrollment(filter_type, running_pipeline, **extra_config)#

Add unenrolled_from field to the user’s profile before un-enrollment.

By modifying the user’s profile before un-enrollment, now the user’s profile will have an unenrolled_from field with the value of the course from which the user is un-enrolling.

Example usage:

>>> OPEN_EDX_FILTERS_CONFIG = {
        "org.openedx.learning.course.unenrollment.started.v1": {
            "fail_silently": False,
            "pipeline": [
                "openedx_filters_samples.pipeline.ModifyUserProfileBeforeUnenrollment"
            ]
        }
    }
run_filter(enrollment, *args, **kwargs)#

Modify the user’s profile before un-enrollment.

Parameters:

enrollment (CourseEnrollment) – The enrollment being un-enrolled.

class openedx_filters_samples.pipeline.ModifyUsernameBeforeRegistration(filter_type, running_pipeline, **extra_config)#

Modify user’s username appending ‘modified’ to the original username before registration.

By modifying the username before registration, now the username will be saved with ‘-modified’ appended to it.

Example usage:

>>> OPEN_EDX_FILTERS_CONFIG = {
    "org.openedx.learning.student.registration.requested.v1": {
        "fail_silently": False,
        "pipeline": [
            "openedx_filters_samples.pipeline.ModifyUsernameBeforeRegistration"
        ]
    }
}
run_filter(form_data, *args, **kwargs)#

Modify the username before registration.

Parameters:

form_data (QueryDict) – The form data containing the user’s registration information.

class openedx_filters_samples.pipeline.NoopFilter(filter_type, running_pipeline, **extra_config)#

Noop filter that does nothing.

Example usage:

>>> OPEN_EDX_FILTERS_CONFIG = {
    "org.openedx.learning.course.enrollment.started.v1": {
        "fail_silently": False,
        "pipeline": [
            "openedx_filters_samples.pipeline.NoopFilter"
        ]
    }
}
run_filter(*args, **kwargs)#

Return an empty dictionary without any modifications to the input data.

class openedx_filters_samples.pipeline.RedirectCustomCourseAbout(filter_type, running_pipeline, **extra_config)#

Redirect to custom course about page.

By raising RedirectToPage exception, the course about render process will be stopped and the user will be redirected to a custom course about page or any other URL.

Example usage:

>>> OPEN_EDX_FILTERS_CONFIG = {
        "org.openedx.learning.course_about.render.started.v1": {
            "fail_silently": False,
            "pipeline": [
                "openedx_filters_samples.pipeline.RedirectCustomCourseAbout"
            ]
        }
    }
run_filter(context, template_name)#

Redirect to custom course about page raising RedirectToPage exception.

Parameters:
  • context (dict) – The context data for the course about page.

  • template_name (str) – The template name for the course about page.

class openedx_filters_samples.pipeline.RedirectToCustomCertificate(filter_type, running_pipeline, **extra_config)#

Redirect to custom certificate page.

By raising RedirectToPage exception, the certificate generation process will be stopped and the user will be redirected to a custom certificate page or any other URL.

Example usage:

>>> OPEN_EDX_FILTERS_CONFIG = {
        "org.openedx.learning.certificate.render.started.v1": {
            "fail_silently": False,
            "pipeline": [
                "openedx_filters_samples.pipeline.RenderCustomCertificateStep"
            ]
        }
    }
run_filter(context, custom_template)#

Raise RedirectToPage exception to redirect the user to a custom certificate page.

Parameters:
  • context (dict) – The context data for the certificate.

  • custom_template (str) – The custom template to render.

class openedx_filters_samples.pipeline.RenderAlternativeCertificate(filter_type, running_pipeline, **extra_config)#

Render alternative certificate raising RenderAlternativeInvalidCertificate exception.

By raising RenderAlternativeInvalidCertificate exception, the certificate generation process will be stopped and an alternative certificate will be rendered. In this case, the default invalid certificate template will be rendered.

Example usage:

>>> OPEN_EDX_FILTERS_CONFIG = {
        "org.openedx.learning.certificate.render.started.v1": {
            "fail_silently": False,
            "pipeline": [
                "openedx_filters_samples.pipeline.RenderAlternativeCertificate"
            ]
        }
    }
run_filter(context, custom_template, *args, **kwargs)#

Raise RenderAlternativeInvalidCertificate exception to alter the certificate generation process.

Parameters:
  • context (dict) – The context data for the certificate.

  • custom_template (str) – The custom template to render.

class openedx_filters_samples.pipeline.RenderAlternativeCourseAbout(filter_type, running_pipeline, **extra_config)#

Alter course about render by raising RenderAlternativeCourseAbout exception.

By raising RenderAlternativeCourseAbout exception, the course about render process will be stopped and an alternative course about page will be rendered. In this case, the default 404 course about template will be rendered.

Example usage:

>>> OPEN_EDX_FILTERS_CONFIG = {
        "org.openedx.learning.course_about.render.started.v1": {
            "fail_silently": False,
            "pipeline": [
                "openedx_filters_samples.pipeline.RenderAlternativeCourseAbout"
            ]
        }
    }
run_filter(context, template_name)#

Render alternative course about page raising RenderAlternativeCourseAbout exception.

When raising the exception, this filter uses a redirect_to field handled by the course about view that redirects to the URL indicated.

Parameters:
  • context (dict) – The context data for the course about page.

  • template_name (str) – The template name for the course about page.

class openedx_filters_samples.pipeline.RenderCustomCertificate(filter_type, running_pipeline, **extra_config)#

Modify the certificate rendering process by creating a custom template.

By creating a custom certificate template, now the certificate will be rendered using the custom template.

Example usage:

>>> OPEN_EDX_FILTERS_CONFIG = {
        "org.openedx.learning.certificate.render.started.v1": {
            "fail_silently": False,
            "pipeline": [
                "openedx_filters_samples.pipeline.RenderCustomCertificate"
            ]
        }
    }
run_filter(context, custom_template)#

Get or create a new custom template to render instead of the original.

Parameters:
  • context (dict) – The context data for the certificate.

  • custom_template (str) – The custom template to render.

class openedx_filters_samples.pipeline.RenderCustomResponseCertificate(filter_type, running_pipeline, **extra_config)#

Alter the certificate generation process by rendering a custom response.

By raising RenderCustomResponse exception, the certificate generation process will be stopped and a custom response will be rendered instead of the certificate.

Example usage:

>>> OPEN_EDX_FILTERS_CONFIG = {
        "org.openedx.learning.certificate.render.started.v1": {
            "fail_silently": False,
            "pipeline": [
                "openedx_filters_samples.pipeline.RenderCustomResponseCertificate"
            ]
        }
    }
run_filter(context, custom_template, *args, **kwargs)#

Raise RenderCustomResponse exception to alter the certificate generation process.

Parameters:
  • context (dict) – The context data for the certificate.

  • custom_template (str) – The custom template to render.

class openedx_filters_samples.pipeline.RenderResponseCourseAbout(filter_type, running_pipeline, **extra_config)#

Alter the course about render process by rendering a custom response.

By raising RenderCustomResponse exception, the course about render process will be stopped and a custom response will be rendered instead of the course about page. In this case, the response will be a simple HttpResponse.

Example usage:

>>> OPEN_EDX_FILTERS_CONFIG = {
        "org.openedx.learning.course_about.render.started.v1": {
            "fail_silently": False,
            "pipeline": [
                "openedx_filters_samples.pipeline.RenderResponseCourseAbout"
            ]
        }
    }
run_filter(context, template_name, *args, **kwargs)#

Raise RenderCustomResponse exception to alter the course about render process.

When raising the exception, this filter uses a redirect_to field handled by the course about view that redirects to the URL indicated.

Parameters:
  • context (dict) – The context data for the course about page.

  • template_name (str) – The custom template to render.

class openedx_filters_samples.pipeline.StopCertificateCreation(filter_type, running_pipeline, **extra_config)#

Stop certificate generation process raising PreventCertificateCreation exception.

By raising PreventCertificateCreation exception, the certificate generation process will be stopped in all cases.

Example usage:

>>> OPEN_EDX_FILTERS_CONFIG = {
    "org.openedx.learning.certificate.creation.requested.v1": {
        "fail_silently": False,
        "pipeline": [
            "openedx_filters_samples.pipeline.StopCertificateCreation"
        ]
    }
}
run_filter(user, course_key, mode, status, grade, generation_mode)#

Raise PreventCertificateCreation exception to stop the certificate generation in all cases.

Parameters:
  • user (User) – The user requesting the certificate.

  • course_key (CourseKey) – The course key for the course.

  • mode (str) – The mode of the certificate.

  • status (str) – The status of the certificate.

  • grade (str) – The grade of the certificate.

  • generation_mode (str) – The generation mode of the certificate.

class openedx_filters_samples.pipeline.StopCohortAssignment(filter_type, running_pipeline, **extra_config)#

Stop cohort assignment for a student by raising PreventCohortAssignment exception.

By raising PreventCohortAssignment exception, the cohort assignment process will be stopped in all cases.

Example usage:

>>> OPEN_EDX_FILTERS_CONFIG = {
        "org.openedx.learning.cohort.assignment.requested.v1": {
            "fail_silently": False,
            "pipeline": [
                "openedx_filters_samples.pipeline.StopCohortAssignment"
            ]
        }
    }
run_filter(user, target_cohort, *args, **kwargs)#

Raise PreventCohortAssignment exception to stop the cohort assignment process in all cases.

Parameters:
  • user (User) – The user being assigned to a cohort.

  • target_cohort (CourseUserGroup) – The target cohort to which the user is being assigned.

class openedx_filters_samples.pipeline.StopCohortChange(filter_type, running_pipeline, **extra_config)#

Stop cohort change by raising PreventCohortChange exception.

By raising PreventCohortChange exception, the cohort change of a student will be stopped in all cases.

Example usage:

>>> OPEN_EDX_FILTERS_CONFIG = {
        "org.openedx.learning.cohort.change.requested.v1": {
            "fail_silently": False,
            "pipeline": [
                "openedx_filters_samples.pipeline.StopCohortChange"
            ]
        }
    }
run_filter(current_membership, target_cohort, *args, **kwargs)#

Raise PreventCohortChange exception to stop the cohort change process in all cases.

Parameters:
  • current_membership (CourseUserGroupMembership) – The current membership of the user.

  • target_cohort (CourseUserGroup) – The target cohort to which the user is changing cohorts.

class openedx_filters_samples.pipeline.StopEnrollment(filter_type, running_pipeline, **extra_config)#

Stop enrollment process raising PreventEnrollment exception.

By raising PreventEnrollment exception, the enrollment process will be stopped in all cases.

Example usage:

>>> OPEN_EDX_FILTERS_CONFIG = {
        "org.openedx.learning.course.enrollment.started.v1": {
            "fail_silently": False,
            "pipeline": [
                "openedx_filters_samples.pipeline.StopEnrollment"
            ]
        }
    }
run_filter(user, course_key, mode, *args, **kwargs)#

Raise PreventEnrollment exception to stop the enrollment process in all cases.

Parameters:
  • user (User) – The user enrolling in the course.

  • course_key (CourseKey) – The course key for the course.

  • mode (str) – The mode of the enrollment.

class openedx_filters_samples.pipeline.StopLogin(filter_type, running_pipeline, **extra_config)#

Stop login process raising PreventLogin exception in all cases.

By raising PreventLogin exception, the login process will be stopped in all cases by raising an error code.

Example usage:

>>> OPEN_EDX_FILTERS_CONFIG = {
        "org.openedx.learning.student.login.requested.v1": {
            "fail_silently": False,
            "pipeline": [
                "openedx_filters_samples.pipeline.StopLogin"
            ]
        }
    }
run_filter(user, *args, **kwargs)#

Raise PreventLogin exception to stop the login process in all cases.

Parameters:

user (User) – The user trying to login.

class openedx_filters_samples.pipeline.StopRegister(filter_type, running_pipeline, **extra_config)#

Stop registration process raising PreventRegister exception.

By raising PreventRegister exception, the registration process will be stopped in all cases by raising a 403 error.

Example usage:

>>> OPEN_EDX_FILTERS_CONFIG = {
        "org.openedx.learning.student.registration.requested.v1": {
            "fail_silently": False,
            "pipeline": [
                "openedx_filters_samples.pipeline.StopRegister"
            ]
        }
    }
run_filter(form_data, *args, **kwargs)#

Raise PreventRegister exception to stop the registration process in all cases.

Parameters:

form_data (QueryDict) – The form data containing the user’s registration information.

class openedx_filters_samples.pipeline.StopUnenrollment(filter_type, running_pipeline, **extra_config)#

Stop un-enrollment process raising StopUnenrollment exception.

By raising StopUnenrollment exception, the un-enrollment from a course will be stopped in all cases.

Example usage:

>>> OPEN_EDX_FILTERS_CONFIG = {
        "org.openedx.learning.course.unenrollment.started.v1": {
            "fail_silently": False,
            "pipeline": [
                "openedx_filters_samples.pipeline.StopUnenrollment"
            ]
        }
    }
run_filter(enrollment, *args, **kwargs)#

Raise PreventUnenrollment exception to stop the un-enrollment process in all cases.

Parameters:

enrollment (CourseEnrollment) – The enrollment being un-enrolled.