Commit 1411fadd by Calen Pennington

Fix access to children via definition

parent 2a96c456
...@@ -111,10 +111,10 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase): ...@@ -111,10 +111,10 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
chapter = module_store.get_item(Location(['i4x', 'edX', 'full', 'chapter','Week_1', None])) chapter = module_store.get_item(Location(['i4x', 'edX', 'full', 'chapter','Week_1', None]))
# make sure the parent no longer points to the child object which was deleted # make sure the parent no longer points to the child object which was deleted
self.assertTrue(sequential.location.url() in chapter.definition['children']) self.assertTrue(sequential.location.url() in chapter.children)
self.client.post(reverse('delete_item'), self.client.post(reverse('delete_item'),
json.dumps({'id': sequential.location.url(), 'delete_children':'true'}), json.dumps({'id': sequential.location.url(), 'delete_children': 'true'}),
"application/json") "application/json")
found = False found = False
...@@ -129,7 +129,7 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase): ...@@ -129,7 +129,7 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
chapter = module_store.get_item(Location(['i4x', 'edX', 'full', 'chapter','Week_1', None])) chapter = module_store.get_item(Location(['i4x', 'edX', 'full', 'chapter','Week_1', None]))
# make sure the parent no longer points to the child object which was deleted # make sure the parent no longer points to the child object which was deleted
self.assertFalse(sequential.location.url() in chapter.definition['children']) self.assertFalse(sequential.location.url() in chapter.children)
......
...@@ -649,9 +649,11 @@ def delete_item(request): ...@@ -649,9 +649,11 @@ def delete_item(request):
for parent_loc in parent_locs: for parent_loc in parent_locs:
parent = modulestore('direct').get_item(parent_loc) parent = modulestore('direct').get_item(parent_loc)
item_url = item_loc.url() item_url = item_loc.url()
if item_url in parent.definition["children"]: if item_url in parent.children:
parent.definition["children"].remove(item_url) children = parent.children
modulestore('direct').update_children(parent.location, parent.definition["children"]) children.remove(item_url)
parent.children = children
modulestore('direct').update_children(parent.location, parent.children)
return HttpResponse() return HttpResponse()
......
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