Skip to content

Commit

Permalink
fix: change filter name and add extra info
Browse files Browse the repository at this point in the history
  • Loading branch information
JuanDavidBuitrago committed Dec 20, 2022
1 parent 9af35fb commit 0b69a66
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
16 changes: 9 additions & 7 deletions openedx_filters/learning/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,25 +444,27 @@ def run_filter(cls, block, context):
return data.get("block"), data.get("context")


class CourseEnrollmentSiteFilterRequested(OpenEdxPublicFilter):
class CourseEnrollmentQuerysetRequested(OpenEdxPublicFilter):
"""
Custom class used to filter user's course enrollments by site.
Custom class used to filter user's course enrollments by site, when a request is made by the user.
Basically it modifies the enrollments queryset.
"""

filter_type = "org.openedx.learning.course_enrollments_site.filter.requested.v1"
filter_type = "org.openedx.learning.course_enrollment_queryset.requested.v1"

class PreventEnrollmentSiteFilter(OpenEdxFilterException):
"""
Custom class used to stop the course enrollment site filter process.
This does not modify the enrollments queryset.
"""

@classmethod
def run_filter(cls, context):
def run_filter(cls, enrollments):
"""
Execute a filter with the signature specified.
Arguments:
context (QuerySet): list of all user's course enrollments
enrollments (QuerySet): data with all user's course enrollments
"""
data = super().run_pipeline(context=context)
return data.get("context")
data = super().run_pipeline(enrollments=enrollments)
return data.get("enrollments")
6 changes: 3 additions & 3 deletions openedx_filters/learning/tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
CohortAssignmentRequested,
CohortChangeRequested,
CourseAboutRenderStarted,
CourseEnrollmentSiteFilterRequested,
CourseEnrollmentQuerysetRequested,
CourseEnrollmentStarted,
CourseUnenrollmentStarted,
DashboardRenderStarted,
Expand Down Expand Up @@ -215,7 +215,7 @@ class TestEnrollmentFilters(TestCase):
- CourseEnrollmentStarted
- CourseUnenrollmentStarted
- CourseEnrollmentSiteFilterRequested
- CourseEnrollmentQuerysetRequested
"""

def test_course_enrollment_started(self):
Expand Down Expand Up @@ -275,7 +275,7 @@ def test_course_enrollments_requested(self):
"""
expected_enrollments = Mock()

enrollments = CourseEnrollmentSiteFilterRequested.run_filter(expected_enrollments)
enrollments = CourseEnrollmentQuerysetRequested.run_filter(expected_enrollments)

self.assertEqual(expected_enrollments, enrollments)

Expand Down

0 comments on commit 0b69a66

Please sign in to comment.