Skip to content

Commit

Permalink
I ❤️ migration 0044: It happens right in the middle between v3 and v4…
Browse files Browse the repository at this point in the history
… principles ...
  • Loading branch information
fsbraun committed May 7, 2024
1 parent 537bc23 commit 8468fc7
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions djangocms_blog/migrations/0044_copy_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,20 @@ def move_plugins_to_blog_content(apps, schema_editor):
translation.delete()

# Resolve placeholders
post_media = get_placeholder_from_slot(post.placeholders, "media")
post_content = get_placeholder_from_slot(post.placeholders, "content")
post_liveblog = get_placeholder_from_slot(post.placeholders, "liveblog")

content_media = get_placeholder_from_slot(content.placeholders, "media")
content_content = get_placeholder_from_slot(content.placeholders, "content")
content_liveblog = get_placeholder_from_slot(content.placeholders, "liveblog")

# Move plugins to post content placeholders
if post_media:
media_plugins = post_media.cmsplugin_set.filter(language=translation.language_code)
if post.media:
media_plugins = post.media.cmsplugin_set.filter(language=translation.language_code)
media_plugins.update(placeholder=content_media)
if post_content:
if post.content:
print("Moving content plugins...")
content_plugins = post_content.cmsplugin_set.filter(language=translation.language_code)
content_plugins = post.content.cmsplugin_set.filter(language=translation.language_code)
content_plugins.update(placeholder=content_content)
if post_liveblog:
live_plugins = post_liveblog.cmsplugin_set.filter(language=translation.language_code)
if post.liveblog:
live_plugins = post.liveblog.cmsplugin_set.filter(language=translation.language_code)
live_plugins.update(placeholder=content_liveblog)


Expand Down

0 comments on commit 8468fc7

Please sign in to comment.