More specific messaging for deprecated block types
TNL-6628
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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},
|
||||
|
||||
@@ -57,7 +57,7 @@ from openedx.core.djangolib.markup import HTML, Text
|
||||
</div>
|
||||
%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="alert announcement">
|
||||
<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
|
||||
</div>
|
||||
%endif
|
||||
|
||||
% if deprecated_blocks_info.get('block_types_enabled'):
|
||||
% if deprecated_blocks_info.get('deprecated_enabled_block_types'):
|
||||
<div class="advance-modules-list">
|
||||
<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(
|
||||
@@ -95,7 +95,7 @@ from openedx.core.djangolib.markup import HTML, Text
|
||||
</p>
|
||||
<nav class="nav-related" aria-label="${_('Unsupported Advance Modules')}">
|
||||
<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>
|
||||
% endfor
|
||||
</ul>
|
||||
|
||||
Reference in New Issue
Block a user