diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 29d134a..95da525 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -14,6 +14,15 @@ Change Log Unreleased ---------- +[1.5.0] - 2023-07-19 +-------------------- + +Added +~~~~~ + +* CourseEnrollmentAPIRenderStarted filter added which can be used to modify the isStarted B2C dashboard rendering process. + + [1.4.0] - 2023-07-18 -------------------- diff --git a/openedx_filters/__init__.py b/openedx_filters/__init__.py index f6d72db..62846b8 100644 --- a/openedx_filters/__init__.py +++ b/openedx_filters/__init__.py @@ -3,4 +3,4 @@ """ from openedx_filters.filters import * -__version__ = "1.4.0" +__version__ = "1.5.0" diff --git a/openedx_filters/learning/filters.py b/openedx_filters/learning/filters.py index 2e7e876..16a7d38 100644 --- a/openedx_filters/learning/filters.py +++ b/openedx_filters/learning/filters.py @@ -591,6 +591,26 @@ def run_filter(cls, course_key, course_home_url): return data.get("course_key"), data.get("course_home_url") +class CourseEnrollmentAPIRenderStarted(OpenEdxPublicFilter): + """ + Custom class used to create filters for enrollment data. + """ + + filter_type = "org.openedx.learning.home.enrollment.api.rendered.v1" + + @classmethod + def run_filter(cls, course_key, serialized_enrollment): + """ + Execute a filter with the specified signature. + + Arguments: + course_key (CourseKey): The course key for which isStarted is being modify. + serialized_enrollment (dict): enrollment data + """ + data = super().run_pipeline(course_key=course_key, serialized_enrollment=serialized_enrollment) + return data.get("course_key"), data.get("serialized_enrollment") + + 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 cefaf76..4c1db26 100644 --- a/openedx_filters/learning/tests/test_filters.py +++ b/openedx_filters/learning/tests/test_filters.py @@ -13,6 +13,7 @@ CohortAssignmentRequested, CohortChangeRequested, CourseAboutRenderStarted, + CourseEnrollmentAPIRenderStarted, CourseEnrollmentQuerysetRequested, CourseEnrollmentStarted, CourseHomeUrlCreationStarted, @@ -604,3 +605,17 @@ def test_course_homeurl_creation_started(self): result = CourseHomeUrlCreationStarted.run_filter(course_key, course_home_url) self.assertTupleEqual((course_key, course_home_url,), result) + + def test_course_enrollment_api_render_started(self): + """ + Test CourseEnrollmentAPIRenderStarted filter behavior under normal conditions. + + Expected behavior: + - The filter must have the signature specified. + - The filter should return course_key and is_started in that order. + """ + course_key, serialized_enrollment = Mock(), Mock() + + result = CourseEnrollmentAPIRenderStarted.run_filter(course_key, serialized_enrollment) + + self.assertTupleEqual((course_key, serialized_enrollment,), result)