Skip to content

Commit

Permalink
feat: add filter to modify the courserun data for externally hosted c…
Browse files Browse the repository at this point in the history
…ourses
  • Loading branch information
jajjibhai008 committed Aug 18, 2023
1 parent 3dd7e3e commit 41bd2f0
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
--------------------

Expand Down
2 changes: 1 addition & 1 deletion openedx_filters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"""
from openedx_filters.filters import *

__version__ = "1.5.0"
__version__ = "1.6.0"
19 changes: 19 additions & 0 deletions openedx_filters/learning/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
15 changes: 15 additions & 0 deletions openedx_filters/learning/tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
CourseEnrollmentQuerysetRequested,
CourseEnrollmentStarted,
CourseHomeUrlCreationStarted,
CourseRunAPIRenderStarted,
CourseUnenrollmentStarted,
DashboardRenderStarted,
InstructorDashboardRenderStarted,
Expand Down Expand Up @@ -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)

0 comments on commit 41bd2f0

Please sign in to comment.