Ticket #13494: bug13494.2.diff

File bug13494.2.diff, 2.3 KB (added by Andi Albrecht, 14 years ago)
  • django/core/mail/__init__.py

    diff --git a/django/core/mail/__init__.py b/django/core/mail/__init__.py
    index d7a868d..8d06422 100644
    a b def mail_admins(subject, message, fail_silently=False, connection=None):  
    8787    """Sends a message to the admins, as defined by the ADMINS setting."""
    8888    if not settings.ADMINS:
    8989        return
    90     EmailMessage(settings.EMAIL_SUBJECT_PREFIX + subject, message,
     90    EmailMessage(u'%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject), message,
    9191                 settings.SERVER_EMAIL, [a[1] for a in settings.ADMINS],
    9292                 connection=connection).send(fail_silently=fail_silently)
    9393
    def mail_managers(subject, message, fail_silently=False, connection=None):  
    9696    """Sends a message to the managers, as defined by the MANAGERS setting."""
    9797    if not settings.MANAGERS:
    9898        return
    99     EmailMessage(settings.EMAIL_SUBJECT_PREFIX + subject, message,
     99    EmailMessage(u'%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject), message,
    100100                 settings.SERVER_EMAIL, [a[1] for a in settings.MANAGERS],
    101101                 connection=connection).send(fail_silently=fail_silently)
    102102
  • tests/regressiontests/mail/tests.py

    diff --git a/tests/regressiontests/mail/tests.py b/tests/regressiontests/mail/tests.py
    index b0c60d8..41e898c 100644
    a b class MailTests(TestCase):  
    343343        settings.ADMINS = old_admins
    344344        settings.MANAGERS = old_managers
    345345
     346    def test_mail_prefix(self):
     347        """Test prefix argument in manager/admin mail."""
     348        # Regression for #13494.
     349        old_admins = settings.ADMINS
     350        old_managers = settings.MANAGERS
     351        settings.ADMINS = settings.MANAGERS = [('nobody','nobody@example.com')]
     352
     353        mail_managers(ugettext_lazy('Subject'), 'Content')
     354        self.assertEqual(len(mail.outbox), 1)
     355        message = mail.outbox[0]
     356        self.assertEqual(message.subject, '[Django] Subject')
     357
     358        mail.outbox = []
     359        mail_admins(ugettext_lazy('Subject'), 'Content')
     360        self.assertEqual(len(mail.outbox), 1)
     361        message = mail.outbox[0]
     362        self.assertEqual(message.subject, '[Django] Subject')
     363
     364        settings.ADMINS = old_admins
     365        settings.MANAGERS = old_managers
     366
Back to Top