Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [AXIMST-467] Manage Tags on block level #2503

Merged
merged 2 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -110,13 +111,15 @@ 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,
"can_duplicate": True,
"can_move": True,
"can_manage_access": True,
"can_delete": True,
"can_manage_tags": can_manage_tags,
}

return actions
Expand All @@ -129,3 +132,4 @@ class VerticalContainerSerializer(serializers.Serializer):

children = ChildVerticalContainerSerializer(many=True)
is_published = serializers.BooleanField()
can_paste_component = serializers.BooleanField()
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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"])
18 changes: 13 additions & 5 deletions cms/djangoapps/contentstore/rest_api/v1/views/vertical_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
},
{
Expand All @@ -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,
}
},
{
Expand All @@ -219,11 +221,13 @@ 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,
}
},
],
"is_published": false
"is_published": false,
"can_paste_component": true,
}
```
"""
Expand All @@ -247,6 +251,10 @@ def get(self, request: Request, usage_key_string: str):
})

is_published = not modulestore().has_changes(current_xblock)
container_data = {"children": children, "is_published": is_published}
container_data = {
"children": children,
"is_published": is_published,
"can_paste_component": True,
}
serializer = VerticalContainerSerializer(container_data)
return Response(serializer.data)
Loading