Skip to content

Commit

Permalink
Use __fake__.User during migration.
Browse files Browse the repository at this point in the history
  • Loading branch information
fsbraun committed Aug 30, 2024
1 parent df0f273 commit 29a799e
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions djangocms_blog/migrations/0044_copy_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
from django.contrib.auth import get_user_model
from django.db import migrations, models

User = get_user_model()


class BareVersion:
"""Patches the save method of a model to standard model save."""
Expand All @@ -23,6 +21,12 @@ def move_plugins_to_blog_content(apps, schema_editor):
"""Adds instances for the new model.
ATTENTION: All fields of the model must have a valid default value!"""

User = apps.get_model(*settings.AUTH_USER_MODEL.split("."))
Post = apps.get_model("djangocms_blog", "Post")
PostContent = apps.get_model("djangocms_blog", "PostContent")
ContentType = apps.get_model("contenttypes", "ContentType")
content_type, _ = ContentType.objects.get_or_create(app_label="djangocms_blog", model="postcontent")

versioning_installed = apps.is_installed("djangocms_versioning")
if versioning_installed:
if getattr(settings, "CMS_MIGRATION_USER_ID", None):
Expand All @@ -32,11 +36,6 @@ def move_plugins_to_blog_content(apps, schema_editor):
else:
migration_user = None

Post = apps.get_model("djangocms_blog", "Post")
PostContent = apps.get_model("djangocms_blog", "PostContent")
ContentType = apps.get_model("contenttypes", "ContentType")
content_type, _ = ContentType.objects.get_or_create(app_label="djangocms_blog", model="postcontent")

for post in Post.objects.all():
if not post.postcontent_set.exists():
# Not yet migrated
Expand Down

0 comments on commit 29a799e

Please sign in to comment.