From 32d2e75c88837fa33f831d89232173c35939b16a Mon Sep 17 00:00:00 2001 From: Jansen Kantor Date: Wed, 21 Jul 2021 09:49:34 -0400 Subject: [PATCH] fix(add teams config service to previewmodulesystem) (#28210) (AU-48) Team ORAs rely on the Teams Config Service to render both the student_view and studio_view in studio. We added the service in e0d57fe1a7, but that appears to only provide it in studio_view. This adds it for student_view. --- cms/djangoapps/contentstore/views/preview.py | 5 +++-- cms/djangoapps/contentstore/views/tests/test_preview.py | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cms/djangoapps/contentstore/views/preview.py b/cms/djangoapps/contentstore/views/preview.py index 6a001924f1..35bec14c3f 100644 --- a/cms/djangoapps/contentstore/views/preview.py +++ b/cms/djangoapps/contentstore/views/preview.py @@ -35,7 +35,7 @@ from xmodule.error_module import ErrorBlock from xmodule.exceptions import NotFoundError, ProcessingError from xmodule.modulestore.django import ModuleI18nService, modulestore from xmodule.partitions.partitions_service import PartitionService -from xmodule.services import SettingsService +from xmodule.services import SettingsService, TeamsConfigurationService from xmodule.studio_editable import has_author_view from xmodule.util.sandboxing import can_execute_unsafe_code, get_python_lib_zip from xmodule.util.xmodule_django import add_webpack_to_fragment @@ -217,7 +217,8 @@ def _preview_module_system(request, descriptor, field_data): "i18n": ModuleI18nService, "settings": SettingsService(), "user": DjangoXBlockUserService(request.user), - "partitions": StudioPartitionService(course_id=course_id) + "partitions": StudioPartitionService(course_id=course_id), + "teams_configuration": TeamsConfigurationService(), }, ) diff --git a/cms/djangoapps/contentstore/views/tests/test_preview.py b/cms/djangoapps/contentstore/views/tests/test_preview.py index f386a5acc0..07bfc85421 100644 --- a/cms/djangoapps/contentstore/views/tests/test_preview.py +++ b/cms/djangoapps/contentstore/views/tests/test_preview.py @@ -169,6 +169,7 @@ class GetPreviewHtmlTestCase(ModuleStoreTestCase): @XBlock.needs("field-data") @XBlock.needs("i18n") @XBlock.needs("user") +@XBlock.needs("teams_configuration") class PureXBlock(XBlock): """ Pure XBlock to use in tests. @@ -192,7 +193,7 @@ class StudioXBlockServiceBindingTest(ModuleStoreTestCase): self.field_data = mock.Mock() @XBlock.register_temp_plugin(PureXBlock, identifier='pure') - @ddt.data("user", "i18n", "field-data") + @ddt.data("user", "i18n", "field-data", "teams_configuration") def test_expected_services_exist(self, expected_service): """ Tests that the 'user' and 'i18n' services are provided by the Studio runtime.