Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[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
Jannis Leidel authored October 11, 2010
4  django/core/mail/__init__.py
@@ -87,7 +87,7 @@ def mail_admins(subject, message, fail_silently=False, connection=None):
87 87
     """Sends a message to the admins, as defined by the ADMINS setting."""
88 88
     if not settings.ADMINS:
89 89
         return
90  
-    EmailMessage(settings.EMAIL_SUBJECT_PREFIX + subject, message,
  90
+    EmailMessage(u'%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject), message,
91 91
                  settings.SERVER_EMAIL, [a[1] for a in settings.ADMINS],
92 92
                  connection=connection).send(fail_silently=fail_silently)
93 93
 
@@ -96,7 +96,7 @@ def mail_managers(subject, message, fail_silently=False, connection=None):
96 96
     """Sends a message to the managers, as defined by the MANAGERS setting."""
97 97
     if not settings.MANAGERS:
98 98
         return
99  
-    EmailMessage(settings.EMAIL_SUBJECT_PREFIX + subject, message,
  99
+    EmailMessage(u'%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject), message,
100 100
                  settings.SERVER_EMAIL, [a[1] for a in settings.MANAGERS],
101 101
                  connection=connection).send(fail_silently=fail_silently)
102 102
 
20  tests/regressiontests/mail/tests.py
@@ -316,3 +316,23 @@ def test_connection_arg(self):
316 316
         settings.ADMINS = old_admins
317 317
         settings.MANAGERS = old_managers
318 318
 
  319
+    def test_mail_prefix(self):
  320
+        """Test prefix argument in manager/admin mail."""
  321
+        # Regression for #13494.
  322
+        old_admins = settings.ADMINS
  323
+        old_managers = settings.MANAGERS
  324
+        settings.ADMINS = settings.MANAGERS = [('nobody','nobody@example.com')]
  325
+
  326
+        mail_managers(ugettext_lazy('Subject'), 'Content')
  327
+        self.assertEqual(len(mail.outbox), 1)
  328
+        message = mail.outbox[0]
  329
+        self.assertEqual(message.subject, '[Django] Subject')
  330
+
  331
+        mail.outbox = []
  332
+        mail_admins(ugettext_lazy('Subject'), 'Content')
  333
+        self.assertEqual(len(mail.outbox), 1)
  334
+        message = mail.outbox[0]
  335
+        self.assertEqual(message.subject, '[Django] Subject')
  336
+
  337
+        settings.ADMINS = old_admins
  338
+        settings.MANAGERS = old_managers

0 notes on commit d327611

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