From ed713d7caa531caa204a7a250a93d61523769ad5 Mon Sep 17 00:00:00 2001 From: Adam Palay Date: Mon, 21 Nov 2016 12:02:49 -0500 Subject: [PATCH] specify if an item is detached --- .../coursegraph/management/commands/dump_to_neo4j.py | 6 ++++-- .../management/commands/tests/test_dump_to_neo4j.py | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/openedx/core/djangoapps/coursegraph/management/commands/dump_to_neo4j.py b/openedx/core/djangoapps/coursegraph/management/commands/dump_to_neo4j.py index aab19ca9a9..65cabcb459 100644 --- a/openedx/core/djangoapps/coursegraph/management/commands/dump_to_neo4j.py +++ b/openedx/core/djangoapps/coursegraph/management/commands/dump_to_neo4j.py @@ -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 diff --git a/openedx/core/djangoapps/coursegraph/management/commands/tests/test_dump_to_neo4j.py b/openedx/core/djangoapps/coursegraph/management/commands/tests/test_dump_to_neo4j.py index 1d41ec1334..0eb9f5d620 100644 --- a/openedx/core/djangoapps/coursegraph/management/commands/tests/test_dump_to_neo4j.py +++ b/openedx/core/djangoapps/coursegraph/management/commands/tests/test_dump_to_neo4j.py @@ -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):