diff --git a/cms/djangoapps/contentstore/views/course.py b/cms/djangoapps/contentstore/views/course.py index df5ba575ae..e1bf0c2d79 100644 --- a/cms/djangoapps/contentstore/views/course.py +++ b/cms/djangoapps/contentstore/views/course.py @@ -535,16 +535,14 @@ def _deprecated_blocks_info(course_module, deprecated_block_types): Returns: Dict with following keys: - block_types (list): list containing types of all deprecated blocks - block_types_enabled (bool): True if any or all `deprecated_blocks` present in Advanced Module List else False - blocks (list): List of `deprecated_block_types` component names and their parent's url + deprecated_enabled_block_types (list): list containing all deprecated blocks types enabled on this course + blocks (list): List of `deprecated_enabled_block_types` instances and their parent's url advance_settings_url (str): URL to advance settings page """ data = { - 'block_types': deprecated_block_types, - 'block_types_enabled': any( - block_type in course_module.advanced_modules for block_type in deprecated_block_types - ), + 'deprecated_enabled_block_types': [ + block_type for block_type in course_module.advanced_modules if block_type in deprecated_block_types + ], 'blocks': [], 'advance_settings_url': reverse_course_url('advanced_settings_handler', course_module.id) } diff --git a/cms/djangoapps/contentstore/views/tests/test_course_index.py b/cms/djangoapps/contentstore/views/tests/test_course_index.py index c38daa6020..9a777f8bb3 100644 --- a/cms/djangoapps/contentstore/views/tests/test_course_index.py +++ b/cms/djangoapps/contentstore/views/tests/test_course_index.py @@ -474,10 +474,9 @@ class TestCourseOutline(CourseTestCase): ] ) - self.assertEqual(info['block_types'], deprecated_block_types) self.assertEqual( - info['block_types_enabled'], - any(component in advanced_modules for component in deprecated_block_types) + info['deprecated_enabled_block_types'], + [component for component in advanced_modules if component in deprecated_block_types] ) self.assertItemsEqual(info['blocks'], expected_blocks) @@ -506,6 +505,28 @@ class TestCourseOutline(CourseTestCase): block_types ) + @ddt.data( + (["a", "b", "c"], ["a", "b", "c"]), + (["a", "b", "c"], ["a", "b", "d"]), + (["a", "b", "c"], ["a", "d", "e"]), + (["a", "b", "c"], ["d", "e", "f"]) + ) + @ddt.unpack + def test_verify_warn_only_on_enabled_modules(self, enabled_block_types, deprecated_block_types): + """ + Verify that we only warn about block_types that are both deprecated and enabled. + """ + expected_block_types = list(set(enabled_block_types) & set(deprecated_block_types)) + course_module = modulestore().get_item(self.course.location) + self._create_test_data(course_module, create_blocks=True, block_types=enabled_block_types) + info = _deprecated_blocks_info(course_module, deprecated_block_types) + self._verify_deprecated_info( + course_module.id, + course_module.advanced_modules, + info, + expected_block_types + ) + @ddt.data( {'delete_vertical': True}, {'delete_vertical': False}, diff --git a/cms/templates/course_outline.html b/cms/templates/course_outline.html index c3753c31d6..366f1e363e 100644 --- a/cms/templates/course_outline.html +++ b/cms/templates/course_outline.html @@ -57,7 +57,7 @@ from openedx.core.djangolib.markup import HTML, Text %endif - %if deprecated_blocks_info.get('blocks') or deprecated_blocks_info.get('block_types_enabled'): + %if deprecated_blocks_info.get('blocks') or deprecated_blocks_info.get('deprecated_enabled_block_types'):
${_("Warning")} @@ -84,7 +84,7 @@ from openedx.core.djangolib.markup import HTML, Text
%endif - % if deprecated_blocks_info.get('block_types_enabled'): + % if deprecated_blocks_info.get('deprecated_enabled_block_types'):

${Text(_("To avoid errors, {platform_name} strongly recommends that you remove unsupported features from the course advanced settings. To do this, go to the {link_start}Advanced Settings page{link_end}, locate the \"Advanced Module List\" setting, and then delete the following modules from the list.")).format( @@ -95,7 +95,7 @@ from openedx.core.djangolib.markup import HTML, Text