forked from CGM_Public/pretix_original
Closes https://github.com/pretix/pretix/issues/293
This commit is contained in:
committed by
Raphael Michel
parent
0990c9cc3d
commit
cb2826f171
@@ -0,0 +1,20 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.11.4 on 2017-08-04 13:42
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('pretixbase', '0071_auto_20170729_1616'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='order',
|
||||||
|
name='download_reminder_sent',
|
||||||
|
field=models.BooleanField(default=False),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -92,6 +92,8 @@ class Order(LoggedModel):
|
|||||||
:type total: decimal.Decimal
|
:type total: decimal.Decimal
|
||||||
:param comment: An internal comment that will only be visible to staff, and never displayed to the user
|
:param comment: An internal comment that will only be visible to staff, and never displayed to the user
|
||||||
:type comment: str
|
:type comment: str
|
||||||
|
:param download_reminder_sent: A field to indicate whether a download reminder has been sent.
|
||||||
|
:type download_reminder_sent: boolean
|
||||||
:param meta_info: Additional meta information on the order, JSON-encoded.
|
:param meta_info: Additional meta information on the order, JSON-encoded.
|
||||||
:type meta_info: str
|
:type meta_info: str
|
||||||
"""
|
"""
|
||||||
@@ -181,6 +183,10 @@ class Order(LoggedModel):
|
|||||||
expiry_reminder_sent = models.BooleanField(
|
expiry_reminder_sent = models.BooleanField(
|
||||||
default=False
|
default=False
|
||||||
)
|
)
|
||||||
|
|
||||||
|
download_reminder_sent = models.BooleanField(
|
||||||
|
default=False
|
||||||
|
)
|
||||||
meta_info = models.TextField(
|
meta_info = models.TextField(
|
||||||
verbose_name=_("Meta information"),
|
verbose_name=_("Meta information"),
|
||||||
null=True, blank=True
|
null=True, blank=True
|
||||||
|
|||||||
@@ -528,6 +528,46 @@ def send_expiry_warnings(sender, **kwargs):
|
|||||||
logger.exception('Reminder email could not be sent')
|
logger.exception('Reminder email could not be sent')
|
||||||
|
|
||||||
|
|
||||||
|
@receiver(signal=periodic_task)
|
||||||
|
def send_download_reminders(sender, **kwargs):
|
||||||
|
eventcache = {}
|
||||||
|
today = now().replace(hour=0, minute=0, second=0)
|
||||||
|
|
||||||
|
for e in Event.objects.filter(date_from__gte=today):
|
||||||
|
eventsettings = eventcache.get(e.pk, None)
|
||||||
|
if eventsettings is None:
|
||||||
|
eventsettings = e.settings
|
||||||
|
eventcache[e.pk] = eventsettings
|
||||||
|
|
||||||
|
days = eventsettings.get('mail_days_download_reminder', as_type=int)
|
||||||
|
if days is not None:
|
||||||
|
continue
|
||||||
|
|
||||||
|
reminder_date = (e.date_from - timedelta(days=days)).replace(hour=0, minute=0, second=0)
|
||||||
|
|
||||||
|
if (today > reminder_date):
|
||||||
|
continue
|
||||||
|
for o in e.orders.filter(status="paid", download_reminder_sent=False):
|
||||||
|
o.download_reminder_sent = True
|
||||||
|
o.save()
|
||||||
|
email_template = eventsettings.mail_text_download_reminder
|
||||||
|
email_context = {
|
||||||
|
'event': o.event.name,
|
||||||
|
'url': build_absolute_uri(o.event, 'presale:event.order', kwargs={
|
||||||
|
'order': o.code,
|
||||||
|
'secret': o.secret
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
email_subject = _('Your ticket is ready for download: %(code)s') % {'code': o.code}
|
||||||
|
try:
|
||||||
|
o.send_mail(
|
||||||
|
email_subject, email_template, email_context,
|
||||||
|
'pretix.event.order.email.expire_warning_sent'
|
||||||
|
)
|
||||||
|
except SendMailException:
|
||||||
|
logger.exception('Reminder email could not be sent')
|
||||||
|
|
||||||
|
|
||||||
class OrderChangeManager:
|
class OrderChangeManager:
|
||||||
error_messages = {
|
error_messages = {
|
||||||
'free_to_paid': _('You cannot change a free order to a paid order.'),
|
'free_to_paid': _('You cannot change a free order to a paid order.'),
|
||||||
|
|||||||
@@ -360,6 +360,21 @@ Your {event} team"""))
|
|||||||
You can change your order details and view the status of your order at
|
You can change your order details and view the status of your order at
|
||||||
{url}
|
{url}
|
||||||
|
|
||||||
|
Best regards,
|
||||||
|
Your {event} team"""))
|
||||||
|
},
|
||||||
|
'mail_days_download_reminder': {
|
||||||
|
'type': int,
|
||||||
|
'default': None
|
||||||
|
},
|
||||||
|
'mail_text_download_reminder': {
|
||||||
|
'type': LazyI18nString,
|
||||||
|
'default': LazyI18nString.from_gettext(ugettext_noop("""Hello,
|
||||||
|
|
||||||
|
you bought a ticket for {event}.
|
||||||
|
|
||||||
|
This is to remind you that your ticket is ready for downloading!
|
||||||
|
|
||||||
Best regards,
|
Best regards,
|
||||||
Your {event} team"""))
|
Your {event} team"""))
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -631,6 +631,13 @@ class MailSettingsForm(SettingsForm):
|
|||||||
validators=[PlaceholderValidator(['{expire_date}', '{event}', '{code}', '{date}', '{url}',
|
validators=[PlaceholderValidator(['{expire_date}', '{event}', '{code}', '{date}', '{url}',
|
||||||
'{invoice_name}', '{invoice_company}'])]
|
'{invoice_name}', '{invoice_company}'])]
|
||||||
)
|
)
|
||||||
|
mail_text_download_reminder = I18nFormField(
|
||||||
|
label=_("Text"),
|
||||||
|
required=False,
|
||||||
|
widget=I18nTextarea,
|
||||||
|
help_text=_("Available placeholders: {event}, {url}"),
|
||||||
|
validators=[PlaceholderValidator(['{event}', '{url}'])]
|
||||||
|
)
|
||||||
smtp_use_custom = forms.BooleanField(
|
smtp_use_custom = forms.BooleanField(
|
||||||
label=_("Use custom SMTP server"),
|
label=_("Use custom SMTP server"),
|
||||||
help_text=_("All mail related to your event will be sent over the smtp server specified by you."),
|
help_text=_("All mail related to your event will be sent over the smtp server specified by you."),
|
||||||
|
|||||||
@@ -42,6 +42,8 @@
|
|||||||
{% blocktrans asvar title_order_custom_mail %}Order custom mail{% endblocktrans %}
|
{% blocktrans asvar title_order_custom_mail %}Order custom mail{% endblocktrans %}
|
||||||
{% include "pretixcontrol/event/mail_settings_fragment.html" with pid="custom_mail" title=title_order_custom_mail items="mail_text_order_custom_mail" %}
|
{% include "pretixcontrol/event/mail_settings_fragment.html" with pid="custom_mail" title=title_order_custom_mail items="mail_text_order_custom_mail" %}
|
||||||
|
|
||||||
|
{% blocktrans asvar title_download_tickets_reminder %}Reminder to download tickets{% endblocktrans %}
|
||||||
|
{% include "pretixcontrol/event/mail_settings_fragment.html" with pid="ticket_reminder" title=title_download_tickets_reminder items="mail_text_download_reminder" %}
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
|
|||||||
Reference in New Issue
Block a user