From 1720deab31988a52a8db27f61e8e71a54792c269 Mon Sep 17 00:00:00 2001 From: Paulo Viadanna Date: Thu, 11 Apr 2024 07:58:30 -0300 Subject: [PATCH] feat: DEFAULT_COURSE_INVITATION_ONLY allow for invitation_only new courses by default (#652) (#653) --- cms/djangoapps/contentstore/tests/test_contentstore.py | 10 ++++++++++ cms/djangoapps/contentstore/views/course.py | 3 ++- cms/envs/common.py | 4 ++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/cms/djangoapps/contentstore/tests/test_contentstore.py b/cms/djangoapps/contentstore/tests/test_contentstore.py index 1eb70347399c..42fde9a3f992 100644 --- a/cms/djangoapps/contentstore/tests/test_contentstore.py +++ b/cms/djangoapps/contentstore/tests/test_contentstore.py @@ -1368,6 +1368,16 @@ def test_create_course_with_unicode_in_id_disabled(self): self.course_data['run'] = '����������' self.assert_create_course_failed(error_message) + @override_settings(DEFAULT_COURSE_INVITATION_ONLY=True) + def test_create_course_invitation_only(self): + """ + Test new course creation with setting: DEFAULT_COURSE_INVITATION_ONLY=True. + """ + test_course_data = self.assert_created_course() + course_id = _get_course_id(self.store, test_course_data) + course = self.store.get_course(course_id) + self.assertEqual(course.invitation_only, True) + def assert_course_permission_denied(self): """ Checks that the course did not get created due to a PermissionError. diff --git a/cms/djangoapps/contentstore/views/course.py b/cms/djangoapps/contentstore/views/course.py index a67a087e144a..3ae5b0aec519 100644 --- a/cms/djangoapps/contentstore/views/course.py +++ b/cms/djangoapps/contentstore/views/course.py @@ -932,8 +932,9 @@ def create_new_course_in_store(store, user, org, number, run, fields): # Set default language from settings and enable web certs fields.update({ - 'language': getattr(settings, 'DEFAULT_COURSE_LANGUAGE', 'en'), 'cert_html_view_enabled': True, + 'invitation_only': getattr(settings, 'DEFAULT_COURSE_INVITATION_ONLY', False), + 'language': getattr(settings, 'DEFAULT_COURSE_LANGUAGE', 'en'), }) with modulestore().default_store(store): diff --git a/cms/envs/common.py b/cms/envs/common.py index 10ec4b3aa084..e2a7b375b839 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -2811,3 +2811,7 @@ #### Event bus publishing #### ## Will be more filled out as part of https://github.com/edx/edx-arch-experiments/issues/381 EVENT_BUS_PRODUCER_CONFIG = {} + +############## Default value for invitation_only when creating courses ############## + +DEFAULT_COURSE_INVITATION_ONLY = False