From dfcf067bc1a584b903a8c5ec9be1612defa05c97 Mon Sep 17 00:00:00 2001 From: Sven Seeberg Date: Mon, 23 Sep 2024 17:43:23 +0200 Subject: [PATCH] Update test data & migrations --- integreat_cms/cms/fixtures/test_data.json | 142 +++++++++--------- ...rchat_language_userchat_region_and_more.py | 27 +++- integreat_cms/cms/models/regions/region.py | 1 + 3 files changed, 96 insertions(+), 74 deletions(-) diff --git a/integreat_cms/cms/fixtures/test_data.json b/integreat_cms/cms/fixtures/test_data.json index 65c1fdc113..8c073f4fe8 100644 --- a/integreat_cms/cms/fixtures/test_data.json +++ b/integreat_cms/cms/fixtures/test_data.json @@ -10,11 +10,6 @@ "mime_type": "application/json" } }, - { - "model": "cms.userchat", - "pk": 1, - "fields": { "device_id": "exampleDeviceID", "zammad_id": 1, "most_recent_hits": "" } - }, { "model": "cms.offertemplate", "pk": 1, @@ -199,7 +194,7 @@ "machine_translate_events": 1, "machine_translate_pois": 1, "integreat_chat_enabled": false, - "zammad_url": "", + "zammad_url": null, "zammad_access_token": "", "zammad_chat_handlers": "", "chat_beta_tester_percentage": 0, @@ -252,7 +247,7 @@ "machine_translate_events": 1, "machine_translate_pois": 1, "integreat_chat_enabled": false, - "zammad_url": "", + "zammad_url": null, "zammad_access_token": "", "zammad_chat_handlers": "", "chat_beta_tester_percentage": 0, @@ -305,7 +300,7 @@ "machine_translate_events": 1, "machine_translate_pois": 1, "integreat_chat_enabled": false, - "zammad_url": "", + "zammad_url": null, "zammad_access_token": "", "zammad_chat_handlers": "", "chat_beta_tester_percentage": 0, @@ -358,7 +353,7 @@ "machine_translate_events": 1, "machine_translate_pois": 1, "integreat_chat_enabled": false, - "zammad_url": "", + "zammad_url": null, "zammad_access_token": "", "zammad_chat_handlers": "", "chat_beta_tester_percentage": 0, @@ -411,7 +406,7 @@ "machine_translate_events": 1, "machine_translate_pois": 1, "integreat_chat_enabled": false, - "zammad_url": "", + "zammad_url": null, "zammad_access_token": "", "zammad_chat_handlers": "", "chat_beta_tester_percentage": 0, @@ -464,7 +459,7 @@ "machine_translate_events": 1, "machine_translate_pois": 1, "integreat_chat_enabled": false, - "zammad_url": "", + "zammad_url": null, "zammad_access_token": "", "zammad_chat_handlers": "", "chat_beta_tester_percentage": 0, @@ -517,72 +512,13 @@ "machine_translate_events": 1, "machine_translate_pois": 1, "integreat_chat_enabled": false, - "zammad_url": "", + "zammad_url": null, "zammad_access_token": "", "zammad_chat_handlers": "", "chat_beta_tester_percentage": 0, "offers": [] } }, - { - "model": "cms.directory", - "pk": 1, - "fields": { - "name": "Test Directory", - "region": null, - "parent": null, - "created_date": "2019-08-11T07:57:42.456Z", - "is_hidden": false - } - }, - { - "model": "cms.directory", - "pk": 2, - "fields": { - "name": "Empty Directory", - "region": null, - "parent": null, - "created_date": "2019-08-11T07:57:42.456Z", - "is_hidden": false - } - }, - { - "model": "cms.mediafile", - "pk": 1, - "fields": { - "file": "global/integreat-logo.png", - "thumbnail": "", - "file_size": 1219, - "type": "image/png", - "name": "Test Logo", - "parent_directory": 1, - "region": null, - "alt_text": "alt text", - "uploaded_date": "2019-08-11T07:57:42.456Z", - "last_modified": "2019-08-11T07:57:42.456Z", - "is_hidden": false - } - }, - { - "model": "cms.mediafile", - "pk": 2, - "fields": { - "file": "global/malte-logo.png", - "thumbnail": "", - "file_size": 1219, - "type": "image/png", - "name": "Test Logo 2", - "parent_directory": null, - "region": null, - "alt_text": "alt text", - "uploaded_date": "2019-08-11T07:57:42.456Z", - "last_modified": "2019-08-11T07:57:42.456Z", - "is_hidden": false - } - }, - { "model": "cms.poicategory", "pk": 1, "fields": { "icon": "service", "color": "#07DC03" } }, - { "model": "cms.poicategory", "pk": 2, "fields": { "icon": "office", "color": "#1DC6C6" } }, - { "model": "cms.poicategory", "pk": 3, "fields": { "icon": "gastronomy", "color": "#2E98FB" } }, { "model": "cms.language", "pk": 1, @@ -793,6 +729,70 @@ "message_partial_live_content_not_available": "Μέρος της σελίδας δεν είναι στη γλώσσα σας. Ωστόσο, το μέρος είναι διαθέσιμο σε αυτές τις γλώσσες:" } }, + { + "model": "cms.userchat", + "pk": 1, + "fields": { "device_id": "exampleDeviceID", "zammad_id": 1, "region": null, "language": 3, "most_recent_hits": "" } + }, + { + "model": "cms.directory", + "pk": 1, + "fields": { + "name": "Test Directory", + "region": null, + "parent": null, + "created_date": "2019-08-11T07:57:42.456Z", + "is_hidden": false + } + }, + { + "model": "cms.directory", + "pk": 2, + "fields": { + "name": "Empty Directory", + "region": null, + "parent": null, + "created_date": "2019-08-11T07:57:42.456Z", + "is_hidden": false + } + }, + { + "model": "cms.mediafile", + "pk": 1, + "fields": { + "file": "global/integreat-logo.png", + "thumbnail": "", + "file_size": 1219, + "type": "image/png", + "name": "Test Logo", + "parent_directory": 1, + "region": null, + "alt_text": "alt text", + "uploaded_date": "2019-08-11T07:57:42.456Z", + "last_modified": "2019-08-11T07:57:42.456Z", + "is_hidden": false + } + }, + { + "model": "cms.mediafile", + "pk": 2, + "fields": { + "file": "global/malte-logo.png", + "thumbnail": "", + "file_size": 1219, + "type": "image/png", + "name": "Test Logo 2", + "parent_directory": null, + "region": null, + "alt_text": "alt text", + "uploaded_date": "2019-08-11T07:57:42.456Z", + "last_modified": "2019-08-11T07:57:42.456Z", + "is_hidden": false + } + }, + { "model": "cms.poicategory", "pk": 1, "fields": { "icon": "service", "color": "#07DC03" } }, + { "model": "cms.poicategory", "pk": 2, "fields": { "icon": "office", "color": "#1DC6C6" } }, + { "model": "cms.poicategory", "pk": 3, "fields": { "icon": "gastronomy", "color": "#2E98FB" } }, { "model": "cms.organization", "pk": 1, diff --git a/integreat_cms/cms/migrations/0103_userchat_language_userchat_region_and_more.py b/integreat_cms/cms/migrations/0103_userchat_language_userchat_region_and_more.py index d157b7b7fd..dd950dded4 100644 --- a/integreat_cms/cms/migrations/0103_userchat_language_userchat_region_and_more.py +++ b/integreat_cms/cms/migrations/0103_userchat_language_userchat_region_and_more.py @@ -1,12 +1,20 @@ -# Generated by Django 4.2.13 on 2024-09-19 06:36 +# Generated by Django 4.2.13 on 2024-09-23 15:33 import django.db.models.deletion from django.db import migrations, models +def set_zammad_urls(apps, schema_editor): # pylint: disable=unused-argument + """ + Update empty Zammad URLs to Null + """ + Region = apps.get_model("cms", "Region") + Region.objects.filter(zammad_url="").update(zammad_url=None) + + class Migration(migrations.Migration): """ - Add relation between user chats, region and language + Add relation between user chats and regions/languages. """ dependencies = [ @@ -36,7 +44,6 @@ class Migration(migrations.Migration): to="cms.region", verbose_name="Region for Chat", ), - preserve_default=False, ), migrations.AlterField( model_name="region", @@ -46,6 +53,20 @@ class Migration(migrations.Migration): default="", help_text="URL pointing to this region's Zammad instance. Setting this enables Zammad form offers.", max_length=256, + null=True, + verbose_name="Zammad-URL", + ), + ), + migrations.RunPython(set_zammad_urls), + migrations.AlterField( + model_name="region", + name="zammad_url", + field=models.URLField( + blank=True, + default="", + help_text="URL pointing to this region's Zammad instance. Setting this enables Zammad form offers.", + max_length=256, + null=True, unique=True, verbose_name="Zammad-URL", ), diff --git a/integreat_cms/cms/models/regions/region.py b/integreat_cms/cms/models/regions/region.py index 06a5cef631..3a4ea8ddb0 100644 --- a/integreat_cms/cms/models/regions/region.py +++ b/integreat_cms/cms/models/regions/region.py @@ -416,6 +416,7 @@ class Region(AbstractBaseModel): zammad_url = models.URLField( max_length=256, blank=True, + null=True, default="", unique=True, verbose_name=_("Zammad-URL"),