Fixed #13494 -- Correctly concat an email subject prefix with a translation string. Thanks, hcarvalhoalves and Andi Albrecht.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14157 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
2ed554bd92
commit
d739737015
|
@ -87,7 +87,7 @@ def mail_admins(subject, message, fail_silently=False, connection=None):
|
|||
"""Sends a message to the admins, as defined by the ADMINS setting."""
|
||||
if not settings.ADMINS:
|
||||
return
|
||||
EmailMessage(settings.EMAIL_SUBJECT_PREFIX + subject, message,
|
||||
EmailMessage(u'%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject), message,
|
||||
settings.SERVER_EMAIL, [a[1] for a in settings.ADMINS],
|
||||
connection=connection).send(fail_silently=fail_silently)
|
||||
|
||||
|
@ -96,7 +96,7 @@ def mail_managers(subject, message, fail_silently=False, connection=None):
|
|||
"""Sends a message to the managers, as defined by the MANAGERS setting."""
|
||||
if not settings.MANAGERS:
|
||||
return
|
||||
EmailMessage(settings.EMAIL_SUBJECT_PREFIX + subject, message,
|
||||
EmailMessage(u'%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject), message,
|
||||
settings.SERVER_EMAIL, [a[1] for a in settings.MANAGERS],
|
||||
connection=connection).send(fail_silently=fail_silently)
|
||||
|
||||
|
|
|
@ -343,3 +343,23 @@ class MailTests(TestCase):
|
|||
settings.ADMINS = old_admins
|
||||
settings.MANAGERS = old_managers
|
||||
|
||||
def test_mail_prefix(self):
|
||||
"""Test prefix argument in manager/admin mail."""
|
||||
# Regression for #13494.
|
||||
old_admins = settings.ADMINS
|
||||
old_managers = settings.MANAGERS
|
||||
settings.ADMINS = settings.MANAGERS = [('nobody','nobody@example.com')]
|
||||
|
||||
mail_managers(ugettext_lazy('Subject'), 'Content')
|
||||
self.assertEqual(len(mail.outbox), 1)
|
||||
message = mail.outbox[0]
|
||||
self.assertEqual(message.subject, '[Django] Subject')
|
||||
|
||||
mail.outbox = []
|
||||
mail_admins(ugettext_lazy('Subject'), 'Content')
|
||||
self.assertEqual(len(mail.outbox), 1)
|
||||
message = mail.outbox[0]
|
||||
self.assertEqual(message.subject, '[Django] Subject')
|
||||
|
||||
settings.ADMINS = old_admins
|
||||
settings.MANAGERS = old_managers
|
||||
|
|
Loading…
Reference in New Issue