Skip to content

Instantly share code, notes, and snippets.

@groovecoder
Created May 29, 2012 19:05
Show Gist options
  • Save groovecoder/2830062 to your computer and use it in GitHub Desktop.
Save groovecoder/2830062 to your computer and use it in GitHub Desktop.
@transaction.commit_on_success(using='default')
def make_breadcrumb_relationships(self, rows):
"""Set the topic_parent for Kuma pages using parent_id"""
log.info("Building parent/child breadcrumb tree...")
for r in rows:
if not r['page_text'].strip():
continue
bc_ids = []
bc_ids.insert(0, r['page_id'])
if r['page_parent']:
bc_ids = self._add_parent_ids(r, bc_ids)
log.info("Migrating breadcrumb ids: %s" % bc_ids)
self._migrate_necessary_mindtouch_pages(bc_ids)
parent_doc = Document.objects.get(mindtouch_page_id=bc_ids.pop(0))
for id in bc_ids:
doc = Document.objects.get(mindtouch_page_id=id)
doc.parent_topic = parent_doc
doc.save()
parent_doc = doc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment