Skip to content

Instantly share code, notes, and snippets.

@zanderle
Created February 4, 2016 15:28
Show Gist options
  • Select an option

  • Save zanderle/048af167a0fe85a86112 to your computer and use it in GitHub Desktop.

Select an option

Save zanderle/048af167a0fe85a86112 to your computer and use it in GitHub Desktop.

Revisions

  1. zanderle created this gist Feb 4, 2016.
    19 changes: 19 additions & 0 deletions migration-plan-pseudo-code.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    # Usecase: I have a DjangoCMS website with content and everything. It is using DjangoCMS Cascade plugin and I'd like
    # to start using Aldryn Bootstrap plugin. I'd like to have a script that migrates all my content from one plugin to
    # the other, since I don't want to do manually.

    # Assuming aldryn_bootstrap is already installed
    # The hard part is to deal with Grid elements, because it has multiple levels. Other stuff (like buttons) can just be replaced

    for container_plugin in all_bootstrap_containers_plugins:
    for row_plugin in container_plugin.get_children().filter(row_plugin=True).order_by(position):
    # Create left sibling of container_plugin
    container_plugin.add_sibling('left', instance=new_row_plugin)
    # For each column in row_plugin, create a new column in newly created row
    for column in row_plugin.get_children().order_by(position):
    new_row_plugin.add_child(instance=new_column)
    # Copy the existing content into the new column
    for plugin in column.get_children():
    plugin.move(target=new_column, 'last-child')
    # Delete the container and all its descendants
    container_plugin.delete()