mirror of
https://github.com/pretix/pretix.git
synced 2026-05-15 16:54:00 +00:00
sendmail: Do not copy rules with subevent when closing an event (Z#23233683) (#6156)
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
from django.db import migrations
|
||||
from django.db.models import F
|
||||
|
||||
|
||||
def remove_cross_event_scheduled_mails(apps, schema_editor):
|
||||
Rule = apps.get_model("sendmail", "Rule")
|
||||
ScheduledMail = apps.get_model("sendmail", "ScheduledMail")
|
||||
ScheduledMail.objects.filter(rule__subevent__isnull=False).exclude(rule__subevent__event=F('rule__event')).delete()
|
||||
Rule.objects.filter(subevent__isnull=False).exclude(subevent__event=F('event')).delete()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("sendmail", "0010_auto_20250801_1342"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(remove_cross_event_scheduled_mails),
|
||||
]
|
||||
@@ -232,7 +232,7 @@ def sendmail_copy_data_receiver(sender, other, item_map, **kwargs):
|
||||
if sender.sendmail_rules.exists(): # idempotency
|
||||
return
|
||||
|
||||
for r in other.sendmail_rules.prefetch_related('limit_products'):
|
||||
for r in other.sendmail_rules.filter(subevent__isnull=True).prefetch_related('limit_products'):
|
||||
limit_products = list(r.limit_products.all())
|
||||
r = copy.copy(r)
|
||||
r.pk = None
|
||||
|
||||
Reference in New Issue
Block a user