From e0c4fdd2b2e8653f677d68b016895c19a39b659b Mon Sep 17 00:00:00 2001 From: Fabian Braun Date: Mon, 26 Aug 2024 19:34:08 +0200 Subject: [PATCH] Fix typo and take migration user from django-cms-4-migration package if set --- djangocms_blog/cms_appconfig.py | 5 ++++- djangocms_blog/migrations/0044_copy_plugins.py | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/djangocms_blog/cms_appconfig.py b/djangocms_blog/cms_appconfig.py index e053921c..ea854587 100644 --- a/djangocms_blog/cms_appconfig.py +++ b/djangocms_blog/cms_appconfig.py @@ -296,7 +296,10 @@ def schemaorg_type(self): return self.gplus_type def __str__(self): - return f"{self.namespace}: {self.get_app_title()} / {self.object_name}" + try: + return f"{self.namespace}: {self.get_app_title()} / {self.object_name}" + except Exception as e: + return str(e) def get_app_instance(request): diff --git a/djangocms_blog/migrations/0044_copy_plugins.py b/djangocms_blog/migrations/0044_copy_plugins.py index 8cb6ea6e..d28e3491 100644 --- a/djangocms_blog/migrations/0044_copy_plugins.py +++ b/djangocms_blog/migrations/0044_copy_plugins.py @@ -1,3 +1,4 @@ +from django.conf import settings from django.contrib.auth import get_user_model from django.db import migrations @@ -8,9 +9,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!""" - versioning_installed = apps.is_installed("djangocms_versisouoning") + versioning_installed = apps.is_installed("djangocms_versioning") if versioning_installed: - migration_user = User.objects.first() + if getattr(settings, "CMS_MIGRATION_USER_ID", None): + migration_user = User.objects.get(pk=settings.CMS_MIGRATION_USER_ID) + else: + migration_user = User.objects.filter(is_superuser=True, is_acitve=True).first() else: migration_user = None