From b4d0c91ad5cb5d255e549d321acca0ede86d0e99 Mon Sep 17 00:00:00 2001 From: Artur Gaspar Date: Wed, 6 Dec 2023 08:18:38 -0300 Subject: [PATCH] fix: make "fs" service available in XBlock preview module system (i.e. in Studio) --- cms/djangoapps/contentstore/views/preview.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cms/djangoapps/contentstore/views/preview.py b/cms/djangoapps/contentstore/views/preview.py index c65e00a0f36a..75ad7753298e 100644 --- a/cms/djangoapps/contentstore/views/preview.py +++ b/cms/djangoapps/contentstore/views/preview.py @@ -160,11 +160,16 @@ def _preview_module_system(request, descriptor, field_data): descriptor: An XModuleDescriptor """ + # Import is placed here to avoid model import at project startup. + import xblock.reference.plugins + course_id = descriptor.location.course_key display_name_only = (descriptor.category == 'static_tab') replace_url_service = ReplaceURLService(course_id=course_id) + fs_service = xblock.reference.plugins.FSService() + wrappers = [ # This wrapper wraps the block in the template specified above partial( @@ -229,7 +234,8 @@ def _preview_module_system(request, descriptor, field_data): "teams_configuration": TeamsConfigurationService(), "sandbox": SandboxService(contentstore=contentstore, course_id=course_id), "cache": CacheService(cache), - 'replace_urls': replace_url_service + 'replace_urls': replace_url_service, + "fs": fs_service }, )