From dcd7c1b1719d6e3a904fc35a9d51fd0bcde4d3bf Mon Sep 17 00:00:00 2001 From: Andrii Date: Wed, 23 Apr 2025 14:31:26 +0300 Subject: [PATCH] refactor: move DEFAULT_ADVANCED_MODULES to hardcoded list instead of settings --- cms/djangoapps/contentstore/views/component.py | 12 +++++++++++- .../contentstore/views/tests/test_block.py | 6 +++--- cms/envs/common.py | 13 ------------- cms/envs/test.py | 10 ---------- 4 files changed, 14 insertions(+), 27 deletions(-) diff --git a/cms/djangoapps/contentstore/views/component.py b/cms/djangoapps/contentstore/views/component.py index 5071245747..ded3b9d2f4 100644 --- a/cms/djangoapps/contentstore/views/component.py +++ b/cms/djangoapps/contentstore/views/component.py @@ -82,6 +82,16 @@ CONTAINER_TEMPLATES = [ "edit-title-button", "edit-upstream-alert", ] +DEFAULT_ADVANCED_MODULES = [ + 'google-calendar', + 'google-document', + 'lti_consumer', + 'poll', + 'split_test', + 'survey', + 'word_cloud', +] + def _advanced_component_types(show_unsupported): """ @@ -445,7 +455,7 @@ def get_component_templates(courselike, library=False): # lint-amnesty, pylint: # These modules should be specified as a list of strings, where the strings # are the names of the modules in ADVANCED_COMPONENT_TYPES that should be # enabled for the course. - course_advanced_keys = list(dict.fromkeys(courselike.advanced_modules + settings.DEFAULT_ADVANCED_MODULES)) + course_advanced_keys = list(dict.fromkeys(courselike.advanced_modules + DEFAULT_ADVANCED_MODULES)) advanced_component_templates = { "type": "advanced", "templates": [], diff --git a/cms/djangoapps/contentstore/views/tests/test_block.py b/cms/djangoapps/contentstore/views/tests/test_block.py index 634fd80f0b..d41856c5cd 100644 --- a/cms/djangoapps/contentstore/views/tests/test_block.py +++ b/cms/djangoapps/contentstore/views/tests/test_block.py @@ -75,7 +75,7 @@ from lms.djangoapps.lms_xblock.mixin import NONSENSICAL_ACCESS_RESTRICTION from openedx.core.djangoapps.discussions.models import DiscussionsConfiguration from openedx.core.djangoapps.content_tagging import api as tagging_api -from ..component import component_handler, get_component_templates +from ..component import component_handler, DEFAULT_ADVANCED_MODULES, get_component_templates from cms.djangoapps.contentstore.xblock_storage_handlers.view_handlers import ( ALWAYS, VisibilityState, @@ -2970,7 +2970,7 @@ class TestComponentTemplates(CourseTestCase): # Check for default advanced modules advanced_templates = self.get_templates_of_type("advanced") advanced_module_keys = [t['category'] for t in advanced_templates] - self.assertCountEqual(advanced_module_keys, settings.DEFAULT_ADVANCED_MODULES) + self.assertCountEqual(advanced_module_keys, DEFAULT_ADVANCED_MODULES) # Now fully disable video through XBlockConfiguration XBlockConfiguration.objects.create(name="video", enabled=False) @@ -3019,7 +3019,7 @@ class TestComponentTemplates(CourseTestCase): Test the handling of advanced component templates. """ self.course.advanced_modules.append("done") - EXPECTED_ADVANCED_MODULES_LENGTH = len(settings.DEFAULT_ADVANCED_MODULES) + 1 + EXPECTED_ADVANCED_MODULES_LENGTH = len(DEFAULT_ADVANCED_MODULES) + 1 self.templates = get_component_templates(self.course) advanced_templates = self.get_templates_of_type("advanced") self.assertEqual(len(advanced_templates), EXPECTED_ADVANCED_MODULES_LENGTH) diff --git a/cms/envs/common.py b/cms/envs/common.py index 4efa3192b3..6cc1938271 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -2938,16 +2938,3 @@ LIBRARY_ENABLED_BLOCKS = [ 'survey', 'word_cloud', ] - -# .. setting_name: DEFAULT_ADVANCED_MODULES -# .. setting_default: ['google-calendar', 'google-document', 'lti_consumer', 'poll', 'split_test', 'survey', 'word_cloud'] -# .. setting_description: List of advanced modules that are enabled by default -DEFAULT_ADVANCED_MODULES = [ - 'google-calendar', - 'google-document', - 'lti_consumer', - 'poll', - 'split_test', - 'survey', - 'word_cloud', -] diff --git a/cms/envs/test.py b/cms/envs/test.py index 98d3ac8bd0..500c8d538d 100644 --- a/cms/envs/test.py +++ b/cms/envs/test.py @@ -336,13 +336,3 @@ COURSE_LIVE_GLOBAL_CREDENTIALS["BIG_BLUE_BUTTON"] = { OPENEDX_LEARNING = { "MEDIA": {"BACKEND": "django.core.files.storage.InMemoryStorage", "OPTIONS": {"location": MEDIA_ROOT + "_private"}} } - -DEFAULT_ADVANCED_MODULES = [ - 'google-calendar', - 'google-document', - 'lti_consumer', - 'poll', - 'split_test', - 'survey', - 'word_cloud', -]