From 1e2a69e22ed74f0c934ea821086659d118b92d57 Mon Sep 17 00:00:00 2001 From: Daniel Clemente Laboreo Date: Thu, 15 Mar 2018 18:11:20 +0200 Subject: [PATCH] Add CourseFields.other_course_settings to store custom fields --- .../contentstore/tests/test_course_settings.py | 16 ++++++++++++++++ .../models/settings/course_metadata.py | 4 ++++ cms/envs/common.py | 4 ++++ common/lib/xmodule/xmodule/course_module.py | 9 +++++++++ 4 files changed, 33 insertions(+) diff --git a/cms/djangoapps/contentstore/tests/test_course_settings.py b/cms/djangoapps/contentstore/tests/test_course_settings.py index c7a03d94de..5c2de94fb2 100644 --- a/cms/djangoapps/contentstore/tests/test_course_settings.py +++ b/cms/djangoapps/contentstore/tests/test_course_settings.py @@ -949,6 +949,22 @@ class CourseMetadataEditingTest(CourseTestCase): ) self.assertNotIn('edxnotes', test_model) + @patch.dict(settings.FEATURES, {'ENABLE_OTHER_COURSE_SETTINGS': True}) + def test_othercoursesettings_present(self): + """ + If feature flag ENABLE_OTHER_COURSE_SETTINGS is on, show the setting in Advanced Settings. + """ + test_model = CourseMetadata.fetch(self.fullcourse) + self.assertIn('other_course_settings', test_model) + + @patch.dict(settings.FEATURES, {'ENABLE_OTHER_COURSE_SETTINGS': False}) + def test_othercoursesettings_not_present(self): + """ + If feature flag ENABLE_OTHER_COURSE_SETTINGS is off, don't show the setting at all in Advanced Settings. + """ + test_model = CourseMetadata.fetch(self.fullcourse) + self.assertNotIn('other_course_settings', test_model) + def test_allow_unsupported_xblocks(self): """ allow_unsupported_xblocks is only shown in Advanced Settings if diff --git a/cms/djangoapps/models/settings/course_metadata.py b/cms/djangoapps/models/settings/course_metadata.py index 5aaf9c5f67..22e2a9bae7 100644 --- a/cms/djangoapps/models/settings/course_metadata.py +++ b/cms/djangoapps/models/settings/course_metadata.py @@ -78,6 +78,10 @@ class CourseMetadata(object): if not settings.FEATURES.get('ENABLE_EDXNOTES'): filtered_list.append('edxnotes') + # Do not show video auto advance if the feature is disabled + if not settings.FEATURES.get('ENABLE_OTHER_COURSE_SETTINGS'): + filtered_list.append('other_course_settings') + # Do not show video_upload_pipeline if the feature is disabled. if not settings.FEATURES.get('ENABLE_VIDEO_UPLOAD_PIPELINE'): filtered_list.append('video_upload_pipeline') diff --git a/cms/envs/common.py b/cms/envs/common.py index 612c434830..331ee29c03 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -236,6 +236,10 @@ FEATURES = { # in sync with the one in lms/envs/common.py 'ENABLE_EDXNOTES': False, + # Show a new field in "Advanced settings" that can store custom data about a + # course and that can be read from themes + 'ENABLE_OTHER_COURSE_SETTINGS': False, + # Enable support for content libraries. Note that content libraries are # only supported in courses using split mongo. 'ENABLE_CONTENT_LIBRARIES': True, diff --git a/common/lib/xmodule/xmodule/course_module.py b/common/lib/xmodule/xmodule/course_module.py index ccb30eff49..574058e5f1 100644 --- a/common/lib/xmodule/xmodule/course_module.py +++ b/common/lib/xmodule/xmodule/course_module.py @@ -853,6 +853,15 @@ class CourseFields(object): ), scope=Scope.settings, default=False ) + other_course_settings = Dict( + display_name=_("Other Course Settings"), + help=_( + "Any additional information about the course that the platform needs or that allows integration with " + "external systems such as CRM software. Enter a dictionary of values in JSON format, such as " + "{ \"my_custom_setting\": \"value\", \"other_setting\": \"value\" }" + ), + scope=Scope.settings + ) class CourseModule(CourseFields, SequenceModule): # pylint: disable=abstract-method