Commit 63f81d8a by Nimisha Asthagiri

fixup! course_api updates from DRF upgrade.

parent 678da3d2
......@@ -21,7 +21,7 @@ class BlockSerializer(serializers.Serializer):
# for example, if student_view_multi_device is false, just don't specify it?
return value if (value is not None) else default
def to_native(self, block_key):
def to_representation(self, block_key):
# create response data dict for basic fields
data = {
'id': unicode(block_key),
......@@ -62,7 +62,7 @@ class BlockDictSerializer(serializers.Serializer):
Serializer that formats to a dictionary, rather than a list, of blocks
"""
root = serializers.CharField(source='root_block_key')
blocks = serializers.SerializerMethodField('get_blocks')
blocks = serializers.SerializerMethodField()
def get_blocks(self, structure):
"""
......
......@@ -56,7 +56,7 @@ class BlockNavigationTransformer(BlockStructureTransformer):
# add self to parent's descendants
for parent_desc_list in parents_descendants_list:
if parent_desc_list is not None:
parent_desc_list.items.append(block_key)
parent_desc_list.items.append(unicode(block_key))
if BlockDepthTransformer.get_block_depth(block_structure, block_key) > self.nav_depth:
children_descendants_list = parents_descendants_list
......
......@@ -49,7 +49,7 @@ class BlockNavigationTransformerTestCase(TestCase, ChildrenMapTestMixin):
for block_key, expected_nav in enumerate(expected_nav_map):
self.assertSetEqual(
set(expected_nav),
set(unicode(block) for block in expected_nav),
set(
block_structure.get_transformer_block_data(
block_key,
......@@ -104,7 +104,7 @@ class BlockNavigationTransformerCourseTestCase(ModuleStoreTestCase):
course_key.make_usage_key('vertical', 'vertical_y1a'),
course_key.make_usage_key('problem', 'problem_y1a_1'),
]:
self.assertIn(block_key, course_descendants)
self.assertIn(unicode(block_key), course_descendants)
# chapter_x and its descendants should not be included
for block_key in [
......@@ -113,4 +113,4 @@ class BlockNavigationTransformerCourseTestCase(ModuleStoreTestCase):
course_key.make_usage_key('vertical', 'vertical_x1a'),
course_key.make_usage_key('problem', 'problem_x1a_1'),
]:
self.assertNotIn(block_key, course_descendants)
self.assertNotIn(unicode(block_key), course_descendants)
......@@ -24,10 +24,10 @@ class CourseBlocks(DeveloperErrorViewMixin, ListAPIView):
GET /api/courses/v1/blocks/<root_block_usage_id>/?depth=all
GET /api/courses/v1/blocks/<usage_id>/?
user=anjali,
&fields=graded,format,multi_device,
&depth=all,
&requested_fields=graded,format,student_view_multi_device,
&block_counts=video,
&student_view_data=video,
&student_view_data.video=mobile_low
**Parameters**:
......@@ -42,7 +42,7 @@ class CourseBlocks(DeveloperErrorViewMixin, ListAPIView):
* requested_fields: (list) Indicates which additional fields to return for each block.
The following fields are always returned: type, display_name
Example: requested_fields=graded,format,student_view_multi_device,children
Example: requested_fields=graded,format,student_view_multi_device
* depth (integer or all) Indicates how deep to traverse into the blocks hierarchy.
A value of all means the entire hierarchy.
......@@ -50,7 +50,11 @@ class CourseBlocks(DeveloperErrorViewMixin, ListAPIView):
Example: depth=all
NOTE: This parameter is currently not honored or supported. For now, it only implements depth=all.
* nav_depth (integer) Indicates how far deep to traverse into the course hierarchy before bundling
all the descendants.
Default is 3 since typical navigational views of the course show a maximum of chapter->sequential->vertical.
Example: nav_depth=3
* return_type (string) Indicates in what data type to return the blocks.
Default is dict. Supported values are: dict, list
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment