Compare commits

...
2 changed files with 31 additions and 0 deletions
@@ -0,0 +1,29 @@
from django.db import migrations
from django.db.models import Exists, OuterRef
def activate_plugin(apps, schema_editor):
Event = apps.get_model("pretixbase", "Event")
ScheduledMail = apps.get_model("sendmail", "ScheduledMail")
events = (
Event.objects
.exclude(plugins__icontains="pretix.plugins.sendmail")
.filter(
Exists(
ScheduledMail.objects.filter(event=OuterRef('pk')).exclude(state=ScheduledMail.STATE_COMPLETED)
)
)
)
for event in events:
event.enable_plugin('pretix.plugins.sendmail')
event.save(update_fields=['plugins'])
class Migration(migrations.Migration):
dependencies = [
("sendmail", "0012_remove_cross_event_scheduled_mails"),
]
operations = [
migrations.RunPython(activate_plugin),
]
+2
View File
@@ -150,6 +150,8 @@ class SendmailPluginRuleLogEntryType(EventLogEntryType):
@receiver(periodic_task)
def sendmail_run_rules(sender, **kwargs):
if "pretix.plugins.sendmail" not in sender.get_plugins():
return # do not send scheduled mails if this plugin is disabled
with scopes_disabled():
mails = ScheduledMail.objects.all()