diff --git a/src/pretix/plugins/returnurl/migrations/0001_initial.py b/src/pretix/plugins/returnurl/migrations/0001_initial.py new file mode 100644 index 0000000000..781fb3dc0a --- /dev/null +++ b/src/pretix/plugins/returnurl/migrations/0001_initial.py @@ -0,0 +1,12 @@ +# Generated by Django 4.2.10 on 2024-03-01 13:55 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ] + + operations = [ + ] diff --git a/src/pretix/plugins/returnurl/migrations/0002_auto_20240301_1355.py b/src/pretix/plugins/returnurl/migrations/0002_auto_20240301_1355.py new file mode 100644 index 0000000000..2fcba8daf5 --- /dev/null +++ b/src/pretix/plugins/returnurl/migrations/0002_auto_20240301_1355.py @@ -0,0 +1,39 @@ +# Generated by Django 4.2.10 on 2024-03-01 13:55 +import re + +from django.core.cache import cache +from django.db import migrations + +MISSING_SLASH = re.compile(r"^https?://[^/]*$") + + +def force_slash_after_hostname(prefix): + prefix = prefix.strip() + if MISSING_SLASH.match(prefix): + return prefix + "/" + else: + return prefix + + +def update_returnurl_prefixes(app, schema_editor): + EventSettingsStore = app.get_model('pretixbase', 'Event_SettingsStore') + + for setting in EventSettingsStore.objects.filter(key='returnurl_prefix'): + prefixes = setting.value.split("\n") + new_prefixes = [force_slash_after_hostname(prefix) for prefix in prefixes] + new_value = "\n".join(new_prefixes) + setting.value = new_value + cache.delete('hierarkey_{}_{}'.format('event', setting.object_id)) + setting.save() + + +class Migration(migrations.Migration): + + dependencies = [ + ('returnurl', '0001_initial'), + ('pretixbase', '0257_item_default_price_not_null'), + ] + + operations = [ + migrations.RunPython(update_returnurl_prefixes, migrations.RunPython.noop) + ] diff --git a/src/pretix/plugins/returnurl/migrations/__init__.py b/src/pretix/plugins/returnurl/migrations/__init__.py new file mode 100644 index 0000000000..e69de29bb2