From c6087e1deb04a0600ba9b259adf1282f6f44218e Mon Sep 17 00:00:00 2001 From: ruzniaievdm Date: Tue, 6 Feb 2024 19:32:43 +0200 Subject: [PATCH] feat: [AXIMST-467] Manage Tags on block level --- .../rest_api/v1/serializers/vertical_block.py | 3 +++ .../v1/views/tests/test_vertical_block.py | 19 +++++++++++++++++-- .../rest_api/v1/views/vertical_block.py | 9 ++++++--- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/cms/djangoapps/contentstore/rest_api/v1/serializers/vertical_block.py b/cms/djangoapps/contentstore/rest_api/v1/serializers/vertical_block.py index a976b4954fac..f63c0ec60814 100644 --- a/cms/djangoapps/contentstore/rest_api/v1/serializers/vertical_block.py +++ b/cms/djangoapps/contentstore/rest_api/v1/serializers/vertical_block.py @@ -5,6 +5,7 @@ from django.urls import reverse from rest_framework import serializers +from cms.djangoapps.contentstore.toggles import use_tagging_taxonomy_list_page from cms.djangoapps.contentstore.helpers import ( xblock_studio_url, xblock_type_display_name, @@ -110,6 +111,7 @@ def get_actions(self, obj): # pylint: disable=unused-argument Method to get actions for each child xlock of the unit. """ + can_manage_tags = use_tagging_taxonomy_list_page() # temporary decision defining the default value 'True' for each xblock. actions = { "can_copy": True, @@ -117,6 +119,7 @@ def get_actions(self, obj): # pylint: disable=unused-argument "can_move": True, "can_manage_access": True, "can_delete": True, + "can_manage_tags": can_manage_tags, } return actions diff --git a/cms/djangoapps/contentstore/rest_api/v1/views/tests/test_vertical_block.py b/cms/djangoapps/contentstore/rest_api/v1/views/tests/test_vertical_block.py index 063ba9ed5420..cd71063ab88a 100644 --- a/cms/djangoapps/contentstore/rest_api/v1/views/tests/test_vertical_block.py +++ b/cms/djangoapps/contentstore/rest_api/v1/views/tests/test_vertical_block.py @@ -3,8 +3,10 @@ """ from django.urls import reverse from rest_framework import status +from edx_toggles.toggles.testutils import override_waffle_flag from cms.djangoapps.contentstore.tests.utils import CourseTestCase +from cms.djangoapps.contentstore.toggles import ENABLE_TAGGING_TAXONOMY_LIST_PAGE from xmodule.partitions.partitions import ENROLLMENT_TRACK_PARTITION_ID from xmodule.modulestore.django import ( modulestore, @@ -148,6 +150,7 @@ def test_xblock_is_published(self): response = self.client.get(url) self.assertTrue(response.data["is_published"]) + @override_waffle_flag(ENABLE_TAGGING_TAXONOMY_LIST_PAGE, True) def test_children_content(self): """ Check that returns valid response with children of vertical container. @@ -187,7 +190,8 @@ def test_children_content(self): "can_duplicate": True, "can_move": True, "can_manage_access": True, - "can_delete": True + "can_delete": True, + "can_manage_tags": True, }, "user_partition_info": expected_user_partition_info, "user_partitions": expected_user_partitions @@ -201,7 +205,8 @@ def test_children_content(self): "can_duplicate": True, "can_move": True, "can_manage_access": True, - "can_delete": True + "can_delete": True, + "can_manage_tags": True, }, "user_partition_info": expected_user_partition_info, "user_partitions": expected_user_partitions, @@ -219,3 +224,13 @@ def test_not_valid_usage_key_string(self): url = self.get_reverse_url(usage_key_string) response = self.client.get(url) self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) + + @override_waffle_flag(ENABLE_TAGGING_TAXONOMY_LIST_PAGE, False) + def test_actions_with_turned_off_taxonomy_flag(self): + """ + Check that action manage_tags for each child item has the same value as taxonomy flag. + """ + url = self.get_reverse_url(self.vertical.location) + response = self.client.get(url) + for children in response.data["children"]: + self.assertFalse(children["actions"]["can_manage_tags"]) 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 a1e87e780bf3..fa3be03057a2 100644 --- a/cms/djangoapps/contentstore/rest_api/v1/views/vertical_block.py +++ b/cms/djangoapps/contentstore/rest_api/v1/views/vertical_block.py @@ -195,7 +195,8 @@ def get(self, request: Request, usage_key_string: str): "can_duplicate": true, "can_move": true, "can_manage_access": true, - "can_delete": true + "can_delete": true, + "can_manage_tags": true, } }, { @@ -207,7 +208,8 @@ def get(self, request: Request, usage_key_string: str): "can_duplicate": true, "can_move": true, "can_manage_access": true, - "can_delete": true + "can_delete": true, + "can_manage_tags": true, } }, { @@ -219,7 +221,8 @@ def get(self, request: Request, usage_key_string: str): "can_duplicate": true, "can_move": true, "can_manage_access": true, - "can_delete": true + "can_delete": true, + "can_manage_tags": true, } }, ],