Fix localization issue in scheduled emails

This commit is contained in:
Raphael Michel
2023-02-07 10:05:26 +01:00
parent 4543d8093f
commit 108408366e
2 changed files with 53 additions and 32 deletions

View File

@@ -28,7 +28,7 @@ from django.core import mail as djmail
from django.utils.timezone import now, utc
from django_scopes import scopes_disabled
from pretix.base.models import Order
from pretix.base.models import InvoiceAddress, Order
from pretix.plugins.sendmail.models import Rule, ScheduledMail
from pretix.plugins.sendmail.signals import sendmail_run_rules
@@ -361,3 +361,22 @@ def test_sendmail_rule_disabled(event, order):
sendmail_run_rules(None)
assert len(djmail.outbox) == 0
@pytest.mark.django_db
@scopes_disabled()
def test_sendmail_context_localization(event, order, pos):
order.locale = 'de'
order.save()
event.settings.name_scheme = 'salutation_given_family'
InvoiceAddress.objects.create(
order=order,
name_parts={'_scheme': 'salutation_given_family', 'salutation': 'Mr', 'given_name': 'Max', 'family_name': 'Mustermann'}
)
djmail.outbox = []
event.sendmail_rules.create(send_date=dt_now - datetime.timedelta(hours=1), include_pending=True,
subject='meow', template='Hallo {name_for_salutation}')
sendmail_run_rules(None)
assert "Hallo Herr Mustermann" in djmail.outbox[0].body