mirror of
https://github.com/pretix/pretix.git
synced 2026-02-05 02:32:28 +00:00
Separate mail template for incomplete payment notifications (#2999)
* Separate mail template for incomplete payment notifications * Update src/pretix/base/settings.py Co-authored-by: Richard Schreiber <wiffbi@gmail.com> * Update src/pretix/control/forms/event.py Co-authored-by: Richard Schreiber <wiffbi@gmail.com> --------- Co-authored-by: Raphael Michel <mail@raphaelmichel.de> Co-authored-by: Richard Schreiber <wiffbi@gmail.com>
This commit is contained in:
@@ -394,6 +394,11 @@ def base_placeholders(sender, **kwargs):
|
||||
lambda event_or_subevent, refund_amount: LazyCurrencyNumber(refund_amount, event_or_subevent.currency),
|
||||
lambda event_or_subevent: LazyCurrencyNumber(Decimal('42.23'), event_or_subevent.currency)
|
||||
),
|
||||
SimpleFunctionalMailTextPlaceholder(
|
||||
'pending_sum', ['event', 'pending_sum'],
|
||||
lambda event, pending_sum: LazyCurrencyNumber(pending_sum, event.currency),
|
||||
lambda event: LazyCurrencyNumber(Decimal('42.23'), event.currency)
|
||||
),
|
||||
SimpleFunctionalMailTextPlaceholder(
|
||||
'total_with_currency', ['event', 'order'], lambda event, order: LazyCurrencyNumber(order.total,
|
||||
event.currency),
|
||||
|
||||
@@ -2019,10 +2019,6 @@ Your {event} team"""))
|
||||
'type': LazyI18nString,
|
||||
'default': LazyI18nString.from_gettext(gettext_noop("Your order is about to expire: {code}")),
|
||||
},
|
||||
'mail_subject_order_pending_warning': {
|
||||
'type': LazyI18nString,
|
||||
'default': LazyI18nString.from_gettext(gettext_noop("Your order is pending payment: {code}")),
|
||||
},
|
||||
'mail_text_order_expire_warning': {
|
||||
'type': LazyI18nString,
|
||||
'default': LazyI18nString.from_gettext(gettext_noop("""Hello,
|
||||
@@ -2037,6 +2033,10 @@ You can view the payment information and the status of your order at
|
||||
Best regards,
|
||||
Your {event} team"""))
|
||||
},
|
||||
'mail_subject_order_pending_warning': {
|
||||
'type': LazyI18nString,
|
||||
'default': LazyI18nString.from_gettext(gettext_noop("Your order is pending payment: {code}")),
|
||||
},
|
||||
'mail_text_order_pending_warning': {
|
||||
'type': LazyI18nString,
|
||||
'default': LazyI18nString.from_gettext(gettext_noop("""Hello,
|
||||
@@ -2047,6 +2047,26 @@ Please keep in mind that you are required to pay before {expire_date}.
|
||||
You can view the payment information and the status of your order at
|
||||
{url}
|
||||
|
||||
Best regards,
|
||||
Your {event} team"""))
|
||||
},
|
||||
'mail_subject_order_incomplete_payment': {
|
||||
'type': LazyI18nString,
|
||||
'default': LazyI18nString.from_gettext(gettext_noop("Incomplete payment received: {code}")),
|
||||
},
|
||||
'mail_text_order_incomplete_payment': {
|
||||
'type': LazyI18nString,
|
||||
'default': LazyI18nString.from_gettext(gettext_noop("""Hello,
|
||||
|
||||
we received a payment for your order for {event}.
|
||||
|
||||
Unfortunately, the received amount is less than the full amount
|
||||
required. Your order is therefore still considered unpaid, as it is
|
||||
missing additional payment of **{pending_sum}**.
|
||||
|
||||
You can view the payment information and the status of your order at
|
||||
{url}
|
||||
|
||||
Best regards,
|
||||
Your {event} team"""))
|
||||
},
|
||||
|
||||
@@ -1072,6 +1072,18 @@ class MailSettingsForm(SettingsForm):
|
||||
required=False,
|
||||
widget=I18nTextInput,
|
||||
)
|
||||
mail_subject_order_incomplete_payment = I18nFormField(
|
||||
label=_("Subject"),
|
||||
required=False,
|
||||
widget=I18nTextInput,
|
||||
)
|
||||
mail_text_order_incomplete_payment = I18nFormField(
|
||||
label=_("Text"),
|
||||
required=False,
|
||||
widget=I18nTextarea,
|
||||
help_text=_("This email only applies to payment methods that can receive incomplete payments, "
|
||||
"such as bank transfer."),
|
||||
)
|
||||
mail_subject_waiting_list = I18nFormField(
|
||||
label=_("Subject"),
|
||||
required=False,
|
||||
@@ -1202,6 +1214,8 @@ class MailSettingsForm(SettingsForm):
|
||||
'mail_text_order_expire_warning': ['event', 'order'],
|
||||
'mail_subject_order_expire_warning': ['event', 'order'],
|
||||
'mail_subject_order_pending_warning': ['event', 'order'],
|
||||
'mail_text_order_incomplete_payment': ['event', 'order'],
|
||||
'mail_subject_order_incomplete_payment': ['event', 'order'],
|
||||
'mail_text_order_custom_mail': ['event', 'order'],
|
||||
'mail_text_download_reminder': ['event', 'order'],
|
||||
'mail_subject_download_reminder': ['event', 'order'],
|
||||
|
||||
@@ -103,7 +103,7 @@
|
||||
{% include "pretixcontrol/event/mail_settings_fragment.html" with pid="order_changed" title=title_order_changed items="mail_subject_order_changed,mail_text_order_changed" %}
|
||||
|
||||
{% blocktrans asvar title_payment_reminder %}Payment reminder{% endblocktrans %}
|
||||
{% include "pretixcontrol/event/mail_settings_fragment.html" with pid="order_expirew" title=title_payment_reminder items="mail_days_order_expire_warning,mail_subject_order_expire_warning,mail_text_order_expire_warning,mail_subject_order_pending_warning,mail_text_order_pending_warning" exclude="mail_days_order_expire_warning" %}
|
||||
{% include "pretixcontrol/event/mail_settings_fragment.html" with pid="order_expirew" title=title_payment_reminder items="mail_days_order_expire_warning,mail_subject_order_expire_warning,mail_text_order_expire_warning,mail_subject_order_pending_warning,mail_text_order_pending_warning,mail_subject_order_incomplete_payment,mail_text_order_incomplete_payment" exclude="mail_days_order_expire_warning" %}
|
||||
|
||||
{% blocktrans asvar title_waiting_list_notification %}Waiting list notification{% endblocktrans %}
|
||||
{% include "pretixcontrol/event/mail_settings_fragment.html" with pid="waiting_list" title=title_waiting_list_notification items="mail_subject_waiting_list,mail_text_waiting_list" %}
|
||||
|
||||
@@ -42,7 +42,7 @@ from django.conf import settings
|
||||
from django.db import transaction
|
||||
from django.db.models import Max, Min, Q
|
||||
from django.db.models.functions import Length
|
||||
from django.utils.translation import gettext, gettext_noop
|
||||
from django.utils.translation import gettext_noop
|
||||
from django_scopes import scope, scopes_disabled
|
||||
|
||||
from pretix.base.email import get_email_context
|
||||
@@ -64,9 +64,9 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
def notify_incomplete_payment(o: Order):
|
||||
with language(o.locale, o.event.settings.region):
|
||||
email_template = o.event.settings.mail_text_order_expire_warning
|
||||
email_context = get_email_context(event=o.event, order=o)
|
||||
email_subject = gettext('Your order received an incomplete payment: %(code)s') % {'code': o.code}
|
||||
email_template = o.event.settings.mail_text_order_incomplete_payment
|
||||
email_context = get_email_context(event=o.event, order=o, pending_sum=o.pending_sum)
|
||||
email_subject = o.event.settings.mail_subject_order_incomplete_payment
|
||||
|
||||
try:
|
||||
o.send_mail(
|
||||
|
||||
@@ -174,7 +174,8 @@ def test_underpaid(env, job):
|
||||
assert env[2].pending_sum == Decimal('0.50')
|
||||
|
||||
assert len(djmail.outbox) == 1
|
||||
assert djmail.outbox[0].subject == 'Your order received an incomplete payment: 1Z3AS'
|
||||
assert djmail.outbox[0].subject == 'Incomplete payment received: 1Z3AS'
|
||||
assert '€0.50' in djmail.outbox[0].body
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
|
||||
Reference in New Issue
Block a user