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
|
||||
:param comment: An internal comment that will only be visible to staff, and never displayed to the user
|
||||
: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.
|
||||
:type meta_info: str
|
||||
"""
|
||||
@@ -181,6 +183,10 @@ class Order(LoggedModel):
|
||||
expiry_reminder_sent = models.BooleanField(
|
||||
default=False
|
||||
)
|
||||
|
||||
download_reminder_sent = models.BooleanField(
|
||||
default=False
|
||||
)
|
||||
meta_info = models.TextField(
|
||||
verbose_name=_("Meta information"),
|
||||
null=True, blank=True
|
||||
|
||||
@@ -528,6 +528,46 @@ def send_expiry_warnings(sender, **kwargs):
|
||||
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:
|
||||
error_messages = {
|
||||
'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
|
||||
{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,
|
||||
Your {event} team"""))
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user