Fix #391 -- Send email on cancelled order (#540)

Send a notification email to user when
order is cancelled.
This commit is contained in:
Daniel
2017-07-06 17:59:48 +08:00
committed by Raphael Michel
parent 9de9d96e35
commit d444935140
8 changed files with 66 additions and 6 deletions

View File

@@ -165,7 +165,7 @@ def mark_order_refunded(order, user=None):
@transaction.atomic
def _cancel_order(order, user=None):
def _cancel_order(order, user=None, send_mail: bool=True):
"""
Mark this order as canceled
:param order: The order to change
@@ -190,6 +190,21 @@ def _cancel_order(order, user=None):
if position.voucher:
Voucher.objects.filter(pk=position.voucher.pk).update(redeemed=F('redeemed') - 1)
if send_mail:
with language(order.locale):
mail(
order.email, _('Order canceled: %(code)s') % {'code': order.code},
order.event.settings.mail_text_order_canceled,
{
'event': order.event.name,
'code': order.code,
'url': build_absolute_uri(order.event, 'presale:event.order', kwargs={
'order': order.code,
'secret': order.secret
})
},
order.event, locale=order.locale
)
return order.pk

View File

@@ -316,6 +316,18 @@ Please note that this link is only valid within the next {hours} hours!
We will reassign the ticket to the next person on the list if you do not
redeem the voucher within that timeframe.
Best regards,
Your {event} team"""))
},
'mail_text_order_canceled': {
'type': LazyI18nString,
'default': LazyI18nString.from_gettext(ugettext_noop("""Hello,
your order {code} for {event} has been canceled.
You can view the details of your order at
{url}
Best regards,
Your {event} team"""))
},

View File

@@ -558,6 +558,13 @@ class MailSettingsForm(SettingsForm):
help_text=_("Available placeholders: {event}, {url}, {product}, {hours}, {code}"),
validators=[PlaceholderValidator(['{event}', '{url}', '{product}', '{hours}', '{code}'])]
)
mail_text_order_canceled = I18nFormField(
label=_("Text"),
required=False,
widget=I18nTextarea,
help_text=_("Available placeholders: {event}, {code}, {url}"),
validators=[PlaceholderValidator(['{event}', '{code}', '{url}'])]
)
smtp_use_custom = forms.BooleanField(
label=_("Use custom SMTP server"),
help_text=_("All mail related to your event will be sent over the smtp server specified by you."),

View File

@@ -35,6 +35,10 @@
{% 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_text_waiting_list" %}
{% blocktrans asvar title_order_canceled %}Order canceled{% endblocktrans %}
{% include "pretixcontrol/event/mail_settings_fragment.html" with pid="order_canceled" title=title_order_canceled items="mail_text_order_canceled" %}
</div>
</fieldset>
<fieldset>

View File

@@ -439,7 +439,8 @@ class MailSettingsPreview(EventPermissionRequiredMixin, View):
'mail_text_resend_all_links': ['event', 'orders'],
'mail_text_order_changed': ['event', 'url', 'invoice_name', 'invoice_company'],
'mail_text_order_expire_warning': ['event', 'url', 'expire_date', 'invoice_name', 'invoice_company'],
'mail_text_waiting_list': ['event', 'url', 'product', 'hours', 'code']
'mail_text_waiting_list': ['event', 'url', 'product', 'hours', 'code'],
'mail_text_order_canceled': ['code', 'event', 'url'],
}
@cached_property

View File

@@ -4421,11 +4421,15 @@ msgstr "Zahlungserinnerung"
msgid "Waiting list notification"
msgstr "Wartelisten-Benachrichtigung"
#: pretix/control/templates/pretixcontrol/event/mail.html:41
#: pretix/control/templates/pretixcontrol/event/mail.html:39
msgid "Order canceled"
msgstr "Bestellung storniert"
#: pretix/control/templates/pretixcontrol/event/mail.html:46
msgid "SMTP settings"
msgstr "SMTP-Einstellungen"
#: pretix/control/templates/pretixcontrol/event/mail.html:55
#: pretix/control/templates/pretixcontrol/event/mail.html:60
msgid "Save and test custom SMTP connection"
msgstr "Speichern und SMTP-Einstellung testen"

View File

@@ -4411,11 +4411,15 @@ msgstr "Zahlungserinnerung"
msgid "Waiting list notification"
msgstr "Wartelisten-Benachrichtigung"
#: pretix/control/templates/pretixcontrol/event/mail.html:41
#: pretix/control/templates/pretixcontrol/event/mail.html:39
msgid "Order canceled"
msgstr "Bestellung storniert"
#: pretix/control/templates/pretixcontrol/event/mail.html:46
msgid "SMTP settings"
msgstr "SMTP-Einstellungen"
#: pretix/control/templates/pretixcontrol/event/mail.html:55
#: pretix/control/templates/pretixcontrol/event/mail.html:60
msgid "Save and test custom SMTP connection"
msgstr "Speichern und SMTP-Einstellung testen"