Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added filter for modifying the isStarted for externally hosted … #106

Merged
merged 1 commit into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.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
--------------------

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.4.0"
__version__ = "1.5.0"
20 changes: 20 additions & 0 deletions openedx_filters/learning/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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 @@ -13,6 +13,7 @@
CohortAssignmentRequested,
CohortChangeRequested,
CourseAboutRenderStarted,
CourseEnrollmentAPIRenderStarted,
CourseEnrollmentQuerysetRequested,
CourseEnrollmentStarted,
CourseHomeUrlCreationStarted,
Expand Down Expand Up @@ -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)