Skip to content

Commit

Permalink
feat: [AXIMST-338] add temporary decision for child action
Browse files Browse the repository at this point in the history
  • Loading branch information
ruzniaievdm committed Feb 22, 2024
1 parent c097996 commit d94201b
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,23 @@ class ChildVerticalContainerSerializer(serializers.Serializer):
name = serializers.CharField(source="display_name_with_default")
block_id = serializers.CharField(source="location")
block_type = serializers.CharField(source="location.block_type")
actions = serializers.SerializerMethodField()

def get_actions(self, obj): # pylint: disable=unused-argument
"""
Method to get actions for each child xlock of the unit.
"""

# 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,
}

return actions


class VerticalContainerSerializer(serializers.Serializer):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,25 @@ def test_children_content(self):
"name": self.html_unit_first.display_name_with_default,
"block_id": str(self.html_unit_first.location),
"block_type": self.html_unit_first.location.block_type,
"actions": {
"can_copy": True,
"can_duplicate": True,
"can_move": True,
"can_manage_access": True,
"can_delete": True
}
},
{
"name": self.html_unit_second.display_name_with_default,
"block_id": str(self.html_unit_second.location),
"block_type": self.html_unit_second.location.block_type,
"actions": {
"can_copy": True,
"can_duplicate": True,
"can_move": True,
"can_manage_access": True,
"can_delete": True
}
},
]
self.assertEqual(response.data["children"], expected_response)
Expand Down
27 changes: 24 additions & 3 deletions cms/djangoapps/contentstore/rest_api/v1/views/vertical_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,17 +180,38 @@ def get(self, request: Request, usage_key_string: str):
{
"name": "Drag and Drop",
"block_id": "block-v1:org+101+101+type@drag-and-drop-v2+block@7599275ace6b46f5a482078a2954ca16",
"block_type": "drag-and-drop-v2"
"block_type": "drag-and-drop-v2",
"actions": {
"can_copy": true,
"can_duplicate": true,
"can_move": true,
"can_manage_access": true,
"can_delete": true
}
},
{
"name": "Video",
"block_id": "block-v1:org+101+101+type@video+block@0e3d39b12d7c4345981bda6b3511a9bf",
"block_type": "video"
"block_type": "video",
"actions": {
"can_copy": true,
"can_duplicate": true,
"can_move": true,
"can_manage_access": true,
"can_delete": true
}
},
{
"name": "Text",
"block_id": "block-v1:org+101+101+type@html+block@3e3fa1f88adb4a108cd14e9002143690",
"block_type": "html"
"block_type": "html",
"actions": {
"can_copy": true,
"can_duplicate": true,
"can_move": true,
"can_manage_access": true,
"can_delete": true
}
},
],
"is_published": false
Expand Down
21 changes: 19 additions & 2 deletions cms/djangoapps/contentstore/views/tests/test_container_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@
from urllib.parse import quote

import cms.djangoapps.contentstore.views.component as views
from common.djangoapps.xblock_django.user_service import DjangoXBlockUserService
from cms.djangoapps.contentstore.tests.test_libraries import LibraryTestCase
from xmodule.modulestore import ModuleStoreEnum # lint-amnesty, pylint: disable=wrong-import-order
from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-order
from xmodule.modulestore.tests.factories import CourseFactory, BlockFactory # lint-amnesty, pylint: disable=wrong-import-order
from xmodule.partitions.partitions import ENROLLMENT_TRACK_PARTITION_ID, UserPartition
from xmodule.partitions.tests.test_partitions import PartitionTestCase

from .utils import StudioPageTestCase


class ContainerPageTestCase(StudioPageTestCase, LibraryTestCase):
class ContainerPageTestCase(StudioPageTestCase, LibraryTestCase, PartitionTestCase):
"""
Unit tests for the container page.
"""
Expand All @@ -34,10 +37,24 @@ def setUp(self):
super().setUp()
self.vertical = self._create_block(self.sequential, 'vertical', 'Unit')
self.html = self._create_block(self.vertical, "html", "HTML")
self.child_container = self._create_block(self.vertical, 'split_test', 'Split Test')
self.user_partition = UserPartition(
ENROLLMENT_TRACK_PARTITION_ID,
self.TEST_NAME,
self.TEST_DESCRIPTION,
self.TEST_GROUPS
)
self.child_container = self._create_block(
self.vertical,
'split_test',
'Split Test',
user_partition_id=ENROLLMENT_TRACK_PARTITION_ID,
user_partitions=[self.user_partition]
)
self.child_vertical = self._create_block(self.child_container, 'vertical', 'Child Vertical')
self.video = self._create_block(self.child_vertical, "video", "My Video")
self.store = modulestore()
user_service = DjangoXBlockUserService(self.user)
self.child_container.runtime._services['user'] = user_service # pylint: disable=protected-access

past = datetime.datetime(1970, 1, 1, tzinfo=UTC)
future = datetime.datetime.now(UTC) + datetime.timedelta(days=1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1090,7 +1090,7 @@ def create_xblock_info( # lint-amnesty, pylint: disable=too-many-statements
"group_access": xblock.group_access,
"user_partitions": user_partitions,
"show_correctness": xblock.show_correctness,
"xblock_type": get_icon(xblock),
"xblock_type": get_icon(xblock) if is_xblock_unit else None,
}
)

Expand Down

0 comments on commit d94201b

Please sign in to comment.