diff --git a/src/pretix/plugins/sendmail/signals.py b/src/pretix/plugins/sendmail/signals.py index cc05479a29..043e7ad765 100644 --- a/src/pretix/plugins/sendmail/signals.py +++ b/src/pretix/plugins/sendmail/signals.py @@ -161,12 +161,14 @@ def sendmail_run_rules(sender, **kwargs): mails.filter( state=ScheduledMail.STATE_SCHEDULED, computed_datetime__lte=timezone.now() - datetime.timedelta(days=2), + event__live=True, ).update( state=ScheduledMail.STATE_MISSED ) for m_id in mails.filter( state__in=(ScheduledMail.STATE_SCHEDULED, ScheduledMail.STATE_FAILED), rule__enabled=True, + event__live=True, computed_datetime__gte=timezone.now() - datetime.timedelta(days=2), computed_datetime__lte=timezone.now(), ).values_list('pk', flat=True): diff --git a/src/pretix/plugins/sendmail/templates/pretixplugins/sendmail/rule_create.html b/src/pretix/plugins/sendmail/templates/pretixplugins/sendmail/rule_create.html index 0dedc62e21..a34e1dc922 100644 --- a/src/pretix/plugins/sendmail/templates/pretixplugins/sendmail/rule_create.html +++ b/src/pretix/plugins/sendmail/templates/pretixplugins/sendmail/rule_create.html @@ -4,6 +4,11 @@ {% block title %}{% trans "Create Email Rule" %}{% endblock %} {% block content %}

{% trans "Create Email Rule" %}

+ {% if not request.event.live %} +
+ {% trans "Automated emails are not sent as long as your ticket shop is offline." %} +
+ {% endif %} {% block inner %}
{% csrf_token %} diff --git a/src/pretix/plugins/sendmail/templates/pretixplugins/sendmail/rule_inspect.html b/src/pretix/plugins/sendmail/templates/pretixplugins/sendmail/rule_inspect.html index 61d7fc4804..e5d0b867da 100644 --- a/src/pretix/plugins/sendmail/templates/pretixplugins/sendmail/rule_inspect.html +++ b/src/pretix/plugins/sendmail/templates/pretixplugins/sendmail/rule_inspect.html @@ -9,6 +9,11 @@ This page shows when your rule is planned to be sent. {% endblocktrans %}

+ {% if not request.event.live %} +
+ {% trans "Automated emails are not sent as long as your ticket shop is offline." %} +
+ {% endif %}
{% trans "Email subject" %}
{{ rule.subject }}
diff --git a/src/pretix/plugins/sendmail/templates/pretixplugins/sendmail/rule_list.html b/src/pretix/plugins/sendmail/templates/pretixplugins/sendmail/rule_list.html index a6138e96d8..d3fe4617e5 100644 --- a/src/pretix/plugins/sendmail/templates/pretixplugins/sendmail/rule_list.html +++ b/src/pretix/plugins/sendmail/templates/pretixplugins/sendmail/rule_list.html @@ -10,6 +10,11 @@ your event. {% endblocktrans %}

+ {% if not request.event.live %} +
+ {% trans "Automated emails are not sent as long as your ticket shop is offline." %} +
+ {% endif %} {% if rules %}

diff --git a/src/pretix/plugins/sendmail/templates/pretixplugins/sendmail/rule_update.html b/src/pretix/plugins/sendmail/templates/pretixplugins/sendmail/rule_update.html index 22d707c3ed..8939323804 100644 --- a/src/pretix/plugins/sendmail/templates/pretixplugins/sendmail/rule_update.html +++ b/src/pretix/plugins/sendmail/templates/pretixplugins/sendmail/rule_update.html @@ -5,6 +5,11 @@ {% block title %}{% trans "Update Email Rule" %}{% endblock %} {% block content %}

{% trans "Update Email Rule" %}

+ {% if not request.event.live %} +
+ {% trans "Automated emails are not sent as long as your ticket shop is offline." %} +
+ {% endif %} {% block inner %} {% csrf_token %} diff --git a/src/tests/plugins/sendmail/conftest.py b/src/tests/plugins/sendmail/conftest.py index 665277ad2c..edd246a11b 100644 --- a/src/tests/plugins/sendmail/conftest.py +++ b/src/tests/plugins/sendmail/conftest.py @@ -33,7 +33,7 @@ def event(): o = Organizer.objects.create(name='Dummy', slug='dummy') event = Event.objects.create( organizer=o, name='Dummy', slug='dummy', - date_from=now(), + date_from=now(), live=True, plugins='pretix.plugins.sendmail,tests.testdummy', ) return event diff --git a/src/tests/plugins/sendmail/test_rules.py b/src/tests/plugins/sendmail/test_rules.py index f56f146dd6..c44a5172cc 100644 --- a/src/tests/plugins/sendmail/test_rules.py +++ b/src/tests/plugins/sendmail/test_rules.py @@ -368,6 +368,20 @@ def test_sendmail_rule_only_send_once(event, order): assert len(djmail.outbox) == 1 +@pytest.mark.django_db +@scopes_disabled() +def test_sendmail_rule_only_live(event, order): + djmail.outbox = [] + event.live = False + event.save() + + event.sendmail_rules.create(send_date=dt_now - datetime.timedelta(hours=1), include_pending=True, + subject='meow', template='meow meow meow') + + sendmail_run_rules(None) + assert len(djmail.outbox) == 0 + + @pytest.mark.django_db @scopes_disabled() def test_sendmail_rule_disabled(event, order):