mirror of
https://github.com/pretix/pretix.git
synced 2026-08-26 13:14:40 +00:00
Only send download reminders if there's actually a download
This commit is contained in:
@@ -1019,7 +1019,6 @@ def send_download_reminders(sender, **kwargs):
|
|||||||
F('event__date_from')
|
F('event__date_from')
|
||||||
)
|
)
|
||||||
).filter(
|
).filter(
|
||||||
status=Order.STATUS_PAID,
|
|
||||||
download_reminder_sent=False,
|
download_reminder_sent=False,
|
||||||
datetime__lte=now() - timedelta(hours=2),
|
datetime__lte=now() - timedelta(hours=2),
|
||||||
first_date__gte=today,
|
first_date__gte=today,
|
||||||
@@ -1049,6 +1048,22 @@ def send_download_reminders(sender, **kwargs):
|
|||||||
if not all([r for rr, r in allow_ticket_download.send(event, order=o)]):
|
if not all([r for rr, r in allow_ticket_download.send(event, order=o)]):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if not o.ticket_download_available:
|
||||||
|
continue
|
||||||
|
positions = o.positions.select_related('item')
|
||||||
|
|
||||||
|
if o.status != Order.STATUS_PAID:
|
||||||
|
if o.status != Order.STATUS_PENDING or o.require_approval or not \
|
||||||
|
o.event.settings.ticket_download_pending:
|
||||||
|
continue
|
||||||
|
send = False
|
||||||
|
for p in positions:
|
||||||
|
if p.generate_ticket:
|
||||||
|
send = True
|
||||||
|
break
|
||||||
|
if not send:
|
||||||
|
continue
|
||||||
|
|
||||||
with language(o.locale):
|
with language(o.locale):
|
||||||
o.download_reminder_sent = True
|
o.download_reminder_sent = True
|
||||||
o.save(update_fields=['download_reminder_sent'])
|
o.save(update_fields=['download_reminder_sent'])
|
||||||
@@ -1066,6 +1081,9 @@ def send_download_reminders(sender, **kwargs):
|
|||||||
|
|
||||||
if event.settings.mail_send_download_reminder_attendee:
|
if event.settings.mail_send_download_reminder_attendee:
|
||||||
for p in o.positions.all():
|
for p in o.positions.all():
|
||||||
|
if not p.generate_ticket:
|
||||||
|
continue
|
||||||
|
|
||||||
if p.subevent_id:
|
if p.subevent_id:
|
||||||
reminder_date = (p.subevent.date_from - timedelta(days=days)).replace(
|
reminder_date = (p.subevent.date_from - timedelta(days=days)).replace(
|
||||||
hour=0, minute=0, second=0, microsecond=0
|
hour=0, minute=0, second=0, microsecond=0
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ def timeline_for_event(event, subevent=None):
|
|||||||
|
|
||||||
if not event.has_subevents:
|
if not event.has_subevents:
|
||||||
days = event.settings.get('mail_days_download_reminder', as_type=int)
|
days = event.settings.get('mail_days_download_reminder', as_type=int)
|
||||||
if days is not None:
|
if days is not None and event.settings.ticket_download:
|
||||||
reminder_date = (ev.date_from - timedelta(days=days)).replace(hour=0, minute=0, second=0, microsecond=0)
|
reminder_date = (ev.date_from - timedelta(days=days)).replace(hour=0, minute=0, second=0, microsecond=0)
|
||||||
tl.append(TimelineEvent(
|
tl.append(TimelineEvent(
|
||||||
event=event, subevent=subevent,
|
event=event, subevent=subevent,
|
||||||
|
|||||||
@@ -445,8 +445,24 @@ class DownloadReminderTests(TestCase):
|
|||||||
order=self.order, item=self.ticket, variation=None,
|
order=self.order, item=self.ticket, variation=None,
|
||||||
price=Decimal("23.00"), attendee_name_parts={"full_name": "Peter"}, positionid=1
|
price=Decimal("23.00"), attendee_name_parts={"full_name": "Peter"}, positionid=1
|
||||||
)
|
)
|
||||||
|
self.event.settings.ticket_download = True
|
||||||
djmail.outbox = []
|
djmail.outbox = []
|
||||||
|
|
||||||
|
@classscope(attr='o')
|
||||||
|
def test_downloads_disabled(self):
|
||||||
|
self.event.settings.mail_days_download_reminder = 2
|
||||||
|
self.event.settings.ticket_download = False
|
||||||
|
send_download_reminders(sender=self.event)
|
||||||
|
assert len(djmail.outbox) == 0
|
||||||
|
|
||||||
|
@classscope(attr='o')
|
||||||
|
def test_downloads_disabled_per_product(self):
|
||||||
|
self.event.settings.mail_days_download_reminder = 2
|
||||||
|
self.ticket.generate_tickets = False
|
||||||
|
self.ticket.save()
|
||||||
|
send_download_reminders(sender=self.event)
|
||||||
|
assert len(djmail.outbox) == 0
|
||||||
|
|
||||||
@classscope(attr='o')
|
@classscope(attr='o')
|
||||||
def test_disabled(self):
|
def test_disabled(self):
|
||||||
send_download_reminders(sender=self.event)
|
send_download_reminders(sender=self.event)
|
||||||
|
|||||||
Reference in New Issue
Block a user