From 4740faa0378545a6dc732abc35afdbd4df85ec45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=86=D0=B2=D0=B0=D0=BD=20=D0=9D=D1=94=D0=B4=D1=94=D0=BB?= =?UTF-8?q?=D1=8C=D0=BD=D1=96=D1=86=D0=B5=D0=B2?= Date: Thu, 21 Mar 2024 09:52:47 +0200 Subject: [PATCH] refactor: [AXIMST-676] change block type to 'lock' if it has a prerequisite --- lms/djangoapps/course_home_api/outline/serializers.py | 4 ++-- lms/djangoapps/course_home_api/outline/tests/test_view.py | 6 +++--- lms/djangoapps/course_home_api/outline/views.py | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lms/djangoapps/course_home_api/outline/serializers.py b/lms/djangoapps/course_home_api/outline/serializers.py index 22c68d77df69..14238ed4ead2 100644 --- a/lms/djangoapps/course_home_api/outline/serializers.py +++ b/lms/djangoapps/course_home_api/outline/serializers.py @@ -43,8 +43,8 @@ def get_blocks(self, block): # pylint: disable=missing-function-docstring description = block['special_exam_info'].get('short_description') icon = block['special_exam_info'].get('suggested_icon', 'fa-pencil-square-o') - if self.context.get('display_block_prerequisite_icon', False) and block.get('accessible') is False: - icon = 'lock' + if self.context.get('enable_prerequisite_block_type', False) and block.get('accessible') is False: + block_type = 'lock' serialized = { block_key: { diff --git a/lms/djangoapps/course_home_api/outline/tests/test_view.py b/lms/djangoapps/course_home_api/outline/tests/test_view.py index 7b2f3c36ae04..1db4bdce3fd9 100644 --- a/lms/djangoapps/course_home_api/outline/tests/test_view.py +++ b/lms/djangoapps/course_home_api/outline/tests/test_view.py @@ -624,12 +624,12 @@ def test_assignment(self): exam_data = response.data['blocks'][str(self.sequential.location)] assert exam_data['display_name'] == 'Test (1 Question)' - assert exam_data['icon'] == 'lock' + assert exam_data['icon'] == 'fa-pencil-square-o' assert str(self.vertical.location) in exam_data['children'] ungraded_data = response.data['blocks'][str(self.ungraded_sequential.location)] assert ungraded_data['display_name'] == 'Ungraded' - assert ungraded_data['icon'] == 'lock' + assert ungraded_data['icon'] is None assert str(self.ungraded_vertical.location) in ungraded_data['children'] @override_waffle_flag(COURSE_ENABLE_UNENROLLED_ACCESS_FLAG, active=True) @@ -669,7 +669,7 @@ def test_hide_learning_sequences(self): assert response.status_code == 200 blocks = response.data['blocks'] - seq_block_id = next(block_id for block_id, block in blocks.items() if block['type'] == 'sequential') + seq_block_id = next(block_id for block_id, block in blocks.items() if block['type'] in ('sequential', 'lock')) # With a course outline loaded, the same sequence is removed. new_learning_seq_outline = CourseOutlineData( diff --git a/lms/djangoapps/course_home_api/outline/views.py b/lms/djangoapps/course_home_api/outline/views.py index cc39ea2d5611..4c8aa24f3d89 100644 --- a/lms/djangoapps/course_home_api/outline/views.py +++ b/lms/djangoapps/course_home_api/outline/views.py @@ -463,7 +463,7 @@ def get(self, request, *args, **kwargs): context.update({ 'include_vertical': True, 'extra_fields': ['special_exam_info',], - 'display_block_prerequisite_icon': True, + 'enable_prerequisite_block_type': True, }) serializer = self.get_serializer_class()(course_blocks, context=context)