diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 95da525b..c8439f18 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -14,6 +14,15 @@ Change Log Unreleased ---------- +[1.6.0] - 2023-08-18 +-------------------- + +Added +~~~~~ + +* CourseRunAPIRenderStarted filter added which can be used to modify the courserun data for B2C dashboard rendering process. + + [1.5.0] - 2023-07-19 -------------------- diff --git a/openedx_filters/__init__.py b/openedx_filters/__init__.py index 62846b8d..f2239440 100644 --- a/openedx_filters/__init__.py +++ b/openedx_filters/__init__.py @@ -3,4 +3,4 @@ """ from openedx_filters.filters import * -__version__ = "1.5.0" +__version__ = "1.6.0" diff --git a/openedx_filters/learning/filters.py b/openedx_filters/learning/filters.py index 16a7d384..3e968d8f 100644 --- a/openedx_filters/learning/filters.py +++ b/openedx_filters/learning/filters.py @@ -611,6 +611,25 @@ def run_filter(cls, course_key, serialized_enrollment): return data.get("course_key"), data.get("serialized_enrollment") +class CourseRunAPIRenderStarted(OpenEdxPublicFilter): + """ + Custom class used to create filters for course run data. + """ + + filter_type = "org.openedx.learning.home.courserun.api.rendered.started.v1" + + @classmethod + def run_filter(cls, serialized_courserun): + """ + Execute a filter with the specified signature. + + Arguments: + serialized_courserun (dict): courserun data + """ + data = super().run_pipeline(serialized_courserun=serialized_courserun) + return data.get("serialized_courserun") + + class InstructorDashboardRenderStarted(OpenEdxPublicFilter): """ Custom class used to create instructor dashboard filters and its custom methods. diff --git a/openedx_filters/learning/tests/test_filters.py b/openedx_filters/learning/tests/test_filters.py index 4c1db263..c8e8f91a 100644 --- a/openedx_filters/learning/tests/test_filters.py +++ b/openedx_filters/learning/tests/test_filters.py @@ -17,6 +17,7 @@ CourseEnrollmentQuerysetRequested, CourseEnrollmentStarted, CourseHomeUrlCreationStarted, + CourseRunAPIRenderStarted, CourseUnenrollmentStarted, DashboardRenderStarted, InstructorDashboardRenderStarted, @@ -619,3 +620,17 @@ def test_course_enrollment_api_render_started(self): result = CourseEnrollmentAPIRenderStarted.run_filter(course_key, serialized_enrollment) self.assertTupleEqual((course_key, serialized_enrollment,), result) + + def test_course_run_api_render_started(self): + """ + Test CourseRunAPIRenderStarted filter behavior under normal conditions. + + Expected behavior: + - The filter must have the signature specified. + - The filter should return serialized_courserun. + """ + serialized_courserun = Mock() + + result = CourseRunAPIRenderStarted.run_filter(serialized_courserun) + + self.assertEqual(serialized_courserun, result)