From a8f74d87eccf65b24f6294b2448b58d2fef14dbb Mon Sep 17 00:00:00 2001 From: Martin Gross Date: Mon, 4 Aug 2025 15:45:17 +0200 Subject: [PATCH] Sendmail: Fix selector for pending/overdue for scheduled messages (Z#23202906) (#5338) * Sendmail: Fix selector for pending/overdue for scheduled messages (Z#287303) * isort * Apply suggestions from code review --------- Co-authored-by: Raphael Michel --- src/pretix/plugins/sendmail/forms.py | 2 +- .../migrations/0010_auto_20250801_1342.py | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 src/pretix/plugins/sendmail/migrations/0010_auto_20250801_1342.py diff --git a/src/pretix/plugins/sendmail/forms.py b/src/pretix/plugins/sendmail/forms.py index 319f5a951..fb69e9654 100644 --- a/src/pretix/plugins/sendmail/forms.py +++ b/src/pretix/plugins/sendmail/forms.py @@ -389,7 +389,7 @@ class RuleForm(FormPlaceholderMixin, I18nModelForm): choices.insert(0, ('n__pending_approval', _('approval pending'))) if not self.event.settings.get('payment_term_expire_automatically', as_type=bool): choices.append( - ('p__overdue', _('pending with payment overdue')) + ('n__pending_overdue', _('pending with payment overdue')) ) self.fields['restrict_to_status'] = forms.MultipleChoiceField( label=pgettext_lazy('sendmail_from', 'Restrict to orders with status'), diff --git a/src/pretix/plugins/sendmail/migrations/0010_auto_20250801_1342.py b/src/pretix/plugins/sendmail/migrations/0010_auto_20250801_1342.py new file mode 100644 index 000000000..15c059bbc --- /dev/null +++ b/src/pretix/plugins/sendmail/migrations/0010_auto_20250801_1342.py @@ -0,0 +1,28 @@ +# Generated by Django 4.2.15 on 2025-08-01 13:42 + +from django.db import migrations + + +def migrate_pending_overdue(apps, schema_editor): + Rule = apps.get_model("sendmail", "Rule") + for r in Rule.objects.filter(restrict_to_status__icontains="p__overdue"): + rts = r.restrict_to_status + rts.remove('p__overdue') + rts.append('n__pending_overdue') + r.restrict_to_status = rts + + r.save(update_fields=["restrict_to_status"]) + + +class Migration(migrations.Migration): + + dependencies = [ + ("sendmail", "0009_auto_20241113_1343"), + ] + + operations = [ + migrations.RunPython( + migrate_pending_overdue, + migrations.RunPython.noop, + ) + ] \ No newline at end of file