forked from CGM_Public/pretix_original
Bank transfer: Migrate to a hybrid plugin (#5394)
* Bank transfer: Migrate to a hybrid plugin * Fix failing tests * Fix test fixtures * Add missing fixture
This commit is contained in:
@@ -24,6 +24,7 @@ from django.utils.functional import cached_property
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from pretix import __version__ as version
|
||||
from pretix.base.plugins import PLUGIN_LEVEL_EVENT_ORGANIZER_HYBRID
|
||||
|
||||
|
||||
class BankTransferApp(AppConfig):
|
||||
@@ -45,6 +46,7 @@ class BankTransferApp(AppConfig):
|
||||
((_("Bank transfer"), _("Import bank data")), "plugins:banktransfer:import", {}),
|
||||
((_("Bank transfer"), _("Export refunds")), "plugins:banktransfer:refunds.list", {}),
|
||||
]
|
||||
level = PLUGIN_LEVEL_EVENT_ORGANIZER_HYBRID
|
||||
|
||||
def ready(self):
|
||||
from . import signals # NOQA
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
# Generated by Django 4.2.16 on 2025-08-20 11:35
|
||||
|
||||
from django.db import migrations
|
||||
from django.db.models import Exists, OuterRef
|
||||
|
||||
|
||||
def activate_plugin(apps, schema_editor):
|
||||
Event = apps.get_model('pretixbase', 'Event')
|
||||
Organizer = apps.get_model('pretixbase', 'Organizer')
|
||||
qs = Organizer.objects.filter(
|
||||
Exists(Event.objects.filter(organizer_id=OuterRef("pk"), plugins__contains="pretix.plugins.banktransfer"))
|
||||
)
|
||||
for org in qs:
|
||||
if "pretix.plugins.banktransfer" not in org.plugins:
|
||||
org.plugins = ",".join(org.plugins.split(",") + ["pretix.plugins.banktransfer"])
|
||||
org.save(update_fields=["plugins"])
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("banktransfer", "0011_banktransaction_external_id"),
|
||||
("pretixbase", "0287_organizer_plugins"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(
|
||||
activate_plugin,
|
||||
migrations.RunPython.noop,
|
||||
)
|
||||
]
|
||||
Reference in New Issue
Block a user