Commit f00f5556 by Eric Fischer

More specific messaging for deprecated block types

TNL-6628
parent ed658ff8
...@@ -535,16 +535,14 @@ def _deprecated_blocks_info(course_module, deprecated_block_types): ...@@ -535,16 +535,14 @@ def _deprecated_blocks_info(course_module, deprecated_block_types):
Returns: Returns:
Dict with following keys: Dict with following keys:
block_types (list): list containing types of all deprecated blocks deprecated_enabled_block_types (list): list containing all deprecated blocks types enabled on this course
block_types_enabled (bool): True if any or all `deprecated_blocks` present in Advanced Module List else False blocks (list): List of `deprecated_enabled_block_types` instances and their parent's url
blocks (list): List of `deprecated_block_types` component names and their parent's url
advance_settings_url (str): URL to advance settings page advance_settings_url (str): URL to advance settings page
""" """
data = { data = {
'block_types': deprecated_block_types, 'deprecated_enabled_block_types': [
'block_types_enabled': any( block_type for block_type in course_module.advanced_modules if block_type in deprecated_block_types
block_type in course_module.advanced_modules for block_type in deprecated_block_types ],
),
'blocks': [], 'blocks': [],
'advance_settings_url': reverse_course_url('advanced_settings_handler', course_module.id) 'advance_settings_url': reverse_course_url('advanced_settings_handler', course_module.id)
} }
......
...@@ -474,10 +474,9 @@ class TestCourseOutline(CourseTestCase): ...@@ -474,10 +474,9 @@ class TestCourseOutline(CourseTestCase):
] ]
) )
self.assertEqual(info['block_types'], deprecated_block_types)
self.assertEqual( self.assertEqual(
info['block_types_enabled'], info['deprecated_enabled_block_types'],
any(component in advanced_modules for component in deprecated_block_types) [component for component in advanced_modules if component in deprecated_block_types]
) )
self.assertItemsEqual(info['blocks'], expected_blocks) self.assertItemsEqual(info['blocks'], expected_blocks)
...@@ -507,6 +506,28 @@ class TestCourseOutline(CourseTestCase): ...@@ -507,6 +506,28 @@ class TestCourseOutline(CourseTestCase):
) )
@ddt.data( @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': True},
{'delete_vertical': False}, {'delete_vertical': False},
) )
......
...@@ -57,7 +57,7 @@ from openedx.core.djangolib.markup import HTML, Text ...@@ -57,7 +57,7 @@ from openedx.core.djangolib.markup import HTML, Text
</div> </div>
%endif %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'):
<div class="wrapper wrapper-alert wrapper-alert-error is-shown"> <div class="wrapper wrapper-alert wrapper-alert-error is-shown">
<div class="alert announcement"> <div class="alert announcement">
<span class="feedback-symbol fa fa-warning" aria-hidden="true"></span><span class="sr">${_("Warning")}</span> <span class="feedback-symbol fa fa-warning" aria-hidden="true"></span><span class="sr">${_("Warning")}</span>
...@@ -84,7 +84,7 @@ from openedx.core.djangolib.markup import HTML, Text ...@@ -84,7 +84,7 @@ from openedx.core.djangolib.markup import HTML, Text
</div> </div>
%endif %endif
% if deprecated_blocks_info.get('block_types_enabled'): % if deprecated_blocks_info.get('deprecated_enabled_block_types'):
<div class="advance-modules-list"> <div class="advance-modules-list">
<p class="advance-modules-remove-text"> <p class="advance-modules-remove-text">
${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( ${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 ...@@ -95,7 +95,7 @@ from openedx.core.djangolib.markup import HTML, Text
</p> </p>
<nav class="nav-related" aria-label="${_('Unsupported Advance Modules')}"> <nav class="nav-related" aria-label="${_('Unsupported Advance Modules')}">
<ul> <ul>
% for block_type in deprecated_blocks_info['block_types']: % for block_type in deprecated_blocks_info['deprecated_enabled_block_types']:
<li class="nav-item">${block_type}</li> <li class="nav-item">${block_type}</li>
% endfor % endfor
</ul> </ul>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment