Commit f77c3512 by Adam Committed by GitHub

Merge pull request #14035 from edx/adam/neo4j-add-detached-field

specify if an item is detached
parents 5b432ede ed713d7c
......@@ -13,6 +13,7 @@ from py2neo import Graph, Node, Relationship, authenticate, NodeSelector
from py2neo.compat import integer, string, unicode as neo4j_unicode
from request_cache.middleware import RequestCache
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.store_utilities import DETACHED_XBLOCK_TYPES
from openedx.core.djangoapps.content.course_structures.models import CourseStructure
......@@ -73,6 +74,7 @@ class ModuleStoreSerializer(object):
)
course_key = item.scope_ids.usage_id.course_key
block_type = item.scope_ids.block_type
# set or reset some defaults
fields['edited_on'] = six.text_type(getattr(item, 'edited_on', ''))
......@@ -82,8 +84,8 @@ class ModuleStoreSerializer(object):
fields['run'] = course_key.run
fields['course_key'] = six.text_type(course_key)
fields['location'] = six.text_type(item.location)
block_type = item.scope_ids.block_type
fields['block_type'] = block_type
fields['detached'] = block_type in DETACHED_XBLOCK_TYPES
if block_type == 'course':
# prune the checklists field
......
......@@ -218,6 +218,8 @@ class TestModuleStoreSerializer(TestDumpToNeo4jCommandBase):
self.assertIn("run", fields.keys())
self.assertIn("course_key", fields.keys())
self.assertIn("location", fields.keys())
self.assertIn("block_type", fields.keys())
self.assertIn("detached", fields.keys())
self.assertNotIn("checklist", fields.keys())
def test_serialize_course(self):
......
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