Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[1.2.X] Fixed #13494 -- Correctly concat an email subject prefix with…

… a translation string. Thanks, hcarvalhoalves and Andi Albrecht.

Backport from trunk (r14157).

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@14159 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit d327611b241e222922cd1161fbbebe4a23f8e485 1 parent cf6b26d
@jezdez jezdez authored
View
4 django/core/mail/__init__.py
@@ -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)
View
20 tests/regressiontests/mail/tests.py
@@ -316,3 +316,23 @@ def test_connection_arg(self):
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

0 comments on commit d327611

Please sign in to comment.
Something went wrong with that request. Please try again.