summaryrefslogtreecommitdiff
path: root/ishtar_common/migrations
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common/migrations')
-rw-r--r--ishtar_common/migrations/0251_data_default_welcome.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/ishtar_common/migrations/0251_data_default_welcome.py b/ishtar_common/migrations/0251_data_default_welcome.py
new file mode 100644
index 000000000..df1f10a5e
--- /dev/null
+++ b/ishtar_common/migrations/0251_data_default_welcome.py
@@ -0,0 +1,39 @@
+# Generated by Django 2.2.24 on 2024-09-26 11:53
+
+from django.conf import settings
+from django.db import migrations
+from django.template import Context, Template
+from django.utils import translation
+
+from ishtar_common.utils_migrations import HOMEPAGE_DEFAULT, HOMEPAGE_TITLE
+
+
+def default_welcome(apps, __):
+ IshtarSiteProfile = apps.get_model("ishtar_common", "IshtarSiteProfile")
+ old_language = translation.get_language()
+ translation.activate(settings.LANGUAGE_CODE)
+ homepage = Template(HOMEPAGE_DEFAULT).render(Context({}, use_l10n=True))
+ title = str(HOMEPAGE_TITLE)
+ translation.activate(old_language)
+ for profile in IshtarSiteProfile.objects.all():
+ changed = False
+ if not profile.homepage:
+ changed = True
+ profile.homepage = homepage
+ if not profile.homepage_title:
+ changed = True
+ profile.homepage_title = title
+ if changed:
+ profile.save()
+
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('ishtar_common', '0250_profile_homepage'),
+ ]
+
+ operations = [
+ migrations.RunPython(default_welcome)
+ ]