Skip to content
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
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ Change Log

Unreleased
~~~~~~~~~~
[0.8.0] - 2022-08-18
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Added
_____

* VerticalBlockChildRenderStarted filter added that is called when every child block of a VericalBlock is about to be rendered.

[0.7.0] - 2022-05-26
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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__ = "0.7.0"
__version__ = "0.8.0"
20 changes: 20 additions & 0 deletions openedx_filters/learning/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,3 +422,23 @@ def run_filter(cls, context, template_name):
"""
data = super().run_pipeline(context=context, template_name=template_name)
return data.get("context"), data.get("template_name")


class VerticalBlockChildRenderStarted(OpenEdxPublicFilter):
"""
Custom class used to create vertical block children's render filters.
"""

filter_type = "org.openedx.learning.vertical_block_child.render.started.v1"

@classmethod
def run_filter(cls, block, context):
"""
Execute a filter with the signature specified.

Arguments:
block (XBlock): the XBlock that is about to be rendered into HTML
context (dict): rendering context values like is_mobile_app, show_title..etc
"""
data = super().run_pipeline(block=block, context=context)
return data.get("block"), data.get("context")
22 changes: 22 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 @@
DashboardRenderStarted,
StudentLoginRequested,
StudentRegistrationRequested,
VerticalBlockChildRenderStarted,
)


Expand Down Expand Up @@ -272,6 +273,7 @@ class TestRenderingFilters(TestCase):

- CourseAboutRenderStarted
- DashboardRenderStarted
- VerticalBlockChildRenderStarted
"""

def setUp(self):
Expand Down Expand Up @@ -354,6 +356,26 @@ def test_halt_course_about_render(self, course_about_exception, attributes):

self.assertDictContainsSubset(attributes, exception.__dict__)

def test_verticalblock_child_render_started(self):
"""
Test VerticalBlockChildRenderStarted filter behavior under normal conditions.

Expected behavior:
- The filter must have the signature specified.
- The filter should return the child block and its context in that order.
"""
block = Mock("child_block")
context = {
"is_mobile_view": False,
"username": "edx",
"child_of_veritcal": True,
"bookmarked": False
}

result = VerticalBlockChildRenderStarted.run_filter(block, context)

self.assertTupleEqual((block, context,), result)


class TestCohortFilters(TestCase):
"""
Expand Down