Skip to content

Commit

Permalink
Merge pull request #106 from jajjibhai008/eahmadjaved/ENT-7373-7374
Browse files Browse the repository at this point in the history
feat: added filter for modifying the isStarted for externally hosted …
  • Loading branch information
felipemontoya committed Aug 2, 2023
2 parents c982791 + ce8d1df commit d741f58
Show file tree
Hide file tree
Showing 4 changed files with 45 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.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)

0 comments on commit d741f58

Please sign in to comment.