From 24695b51e099e1399eb1ce516b3f52c607139875 Mon Sep 17 00:00:00 2001 From: ruzniaievdm Date: Thu, 15 Feb 2024 18:18:27 +0200 Subject: [PATCH] fix: resolve discussions --- .../rest_api/v1/views/vertical_block.py | 8 ++++---- cms/djangoapps/contentstore/utils.py | 13 ++++++------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/cms/djangoapps/contentstore/rest_api/v1/views/vertical_block.py b/cms/djangoapps/contentstore/rest_api/v1/views/vertical_block.py index 5da5e9a5e50b..d92844cb471c 100644 --- a/cms/djangoapps/contentstore/rest_api/v1/views/vertical_block.py +++ b/cms/djangoapps/contentstore/rest_api/v1/views/vertical_block.py @@ -10,8 +10,8 @@ get_container_handler_context, get_user_partition_info, get_visibility_partition_info, - get_validation_messages, - get_render_error, + get_xblock_validation_messages, + get_xblock_render_error, ) from cms.djangoapps.contentstore.views.component import _get_item_in_course from cms.djangoapps.contentstore.xblock_storage_handlers.view_handlers import get_xblock @@ -240,8 +240,8 @@ def get(self, request: Request, usage_key_string: str): child_info = modulestore().get_item(child) user_partition_info = get_visibility_partition_info(child_info, course=course) user_partitions = get_user_partition_info(child_info, course=course) - validation_messages = get_validation_messages(child_info) - render_error = get_render_error(request, child_info) + validation_messages = get_xblock_validation_messages(child_info) + render_error = get_xblock_render_error(request, child_info) children.append({ "name": child_info.display_name_with_default, diff --git a/cms/djangoapps/contentstore/utils.py b/cms/djangoapps/contentstore/utils.py index 5297af1ad20d..3d30b8328139 100644 --- a/cms/djangoapps/contentstore/utils.py +++ b/cms/djangoapps/contentstore/utils.py @@ -2141,7 +2141,7 @@ def track_course_update_event(course_key, user, event_data=None): tracker.emit(event_name, event_data) -def get_validation_messages(xblock): +def get_xblock_validation_messages(xblock): """ Retrieves validation messages for a given xblock. @@ -2155,7 +2155,7 @@ def get_validation_messages(xblock): return validation_json['messages'] -def get_render_error(request, xblock): +def get_xblock_render_error(request, xblock): """ Checks if there are any rendering errors for a given block and return these. @@ -2170,7 +2170,7 @@ def get_render_error(request, xblock): from xmodule.studio_editable import has_author_view from xmodule.x_module import AUTHOR_VIEW, STUDENT_VIEW - def get_render_context(request, block): + def get_xblock_render_context(request, block): """ Return a dict of the data needs for render of each block. """ @@ -2187,13 +2187,12 @@ def get_render_context(request, block): "tags_count_map": {}, } - render_error = "" try: block = _load_preview_block(request, xblock) preview_view = AUTHOR_VIEW if has_author_view(block) else STUDENT_VIEW - render_context = get_render_context(request, block) + render_context = get_xblock_render_context(request, block) block.render(preview_view, render_context) except Exception as exc: # pylint: disable=broad-except - render_error = str(exc) + return str(exc) - return render_error + return ""