[damned-lies] Fix usage of EMAIL_SUBJECT_PREFIX



commit 0102f77e61c9cc27cfd079355a7af38ff64ba051
Author: Pino Toscano <toscano pino tiscali it>
Date:   Thu Apr 25 22:50:36 2019 +0200

    Fix usage of EMAIL_SUBJECT_PREFIX
    
    In Django [1] this string is supposed to include a trailing space, and
    indeed internal Django functions assume there is one.
    Hence, adapt damnedlies to this assuption.
    
    [1] https://docs.djangoproject.com/en/2.2/ref/settings/#email-subject-prefix

 common/utils.py         | 2 +-
 damnedlies/settings.py  | 2 +-
 teams/tests.py          | 4 ++--
 vertimus/tests/tests.py | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/common/utils.py b/common/utils.py
index 64609bd6..157c1079 100644
--- a/common/utils.py
+++ b/common/utils.py
@@ -91,5 +91,5 @@ def get_user_locale(request):
 def send_mail(subject, message, **kwargs):
     """Wrapper to Django's send_mail allowing all EmailMessage init arguments."""
     if not subject.startswith(settings.EMAIL_SUBJECT_PREFIX):
-        subject = '%s %s' % (settings.EMAIL_SUBJECT_PREFIX, subject)
+        subject = '%s%s' % (settings.EMAIL_SUBJECT_PREFIX, subject)
     EmailMessage(subject, message, **kwargs).send()
diff --git a/damnedlies/settings.py b/damnedlies/settings.py
index ccef97a6..f11a7f80 100644
--- a/damnedlies/settings.py
+++ b/damnedlies/settings.py
@@ -24,7 +24,7 @@ DATABASES = {
 EMAIL_HOST = 'localhost'
 EMAIL_HOST_USER = ''
 EMAIL_HOST_PASSWORD = ''
-EMAIL_SUBJECT_PREFIX = '[Damned Lies]'
+EMAIL_SUBJECT_PREFIX = '[Damned Lies] '
 EMAIL_HEADER_NAME= 'X-Vertimus'
 DEFAULT_FROM_EMAIL = 'gnomeweb gnome org'
 SERVER_EMAIL = 'gnomeweb gnome org'
diff --git a/teams/tests.py b/teams/tests.py
index dae82479..470eedd4 100644
--- a/teams/tests.py
+++ b/teams/tests.py
@@ -205,14 +205,14 @@ class TeamTests(TeamsAndRolesMixin, TestCase):
     def test_send_mail_to_coordinator(self):
         self.t.send_mail_to_coordinator(subject="foo", message="bar")
         self.assertEqual(len(mail.outbox), 1)
-        self.assertEqual(mail.outbox[0].subject, "%s foo" % settings.EMAIL_SUBJECT_PREFIX)
+        self.assertEqual(mail.outbox[0].subject, "%sfoo" % settings.EMAIL_SUBJECT_PREFIX)
         self.assertEqual(mail.outbox[0].extra_headers, {settings.EMAIL_HEADER_NAME: 'coordinator-mail'})
         # the message is sent in the language of the team
         self.t.send_mail_to_coordinator(subject=ugettext_lazy("About Damned Lies"), message="...")
         self.assertEqual(len(mail.outbox), 2)
         self.assertEqual(
             mail.outbox[1].subject,
-            "%s À propos de Damned Lies" % settings.EMAIL_SUBJECT_PREFIX
+            "%sÀ propos de Damned Lies" % settings.EMAIL_SUBJECT_PREFIX
         )
 
 
diff --git a/vertimus/tests/tests.py b/vertimus/tests/tests.py
index 6f1b5705..b5515b12 100644
--- a/vertimus/tests/tests.py
+++ b/vertimus/tests/tests.py
@@ -305,7 +305,7 @@ class VertimusTest(TeamsAndRolesMixin, TestCase):
         # Mail sent to mailing list
         self.assertEqual(len(mail.outbox), 1)
         self.assertEqual(mail.outbox[0].recipients(), [self.l.team.mailing_list])
-        self.assertEqual(mail.outbox[0].subject, "%s gnome-hello - gnome-2-24" % 
settings.EMAIL_SUBJECT_PREFIX)
+        self.assertEqual(mail.outbox[0].subject, "%sgnome-hello - gnome-2-24" % 
settings.EMAIL_SUBJECT_PREFIX)
         self.assertEqual(mail.outbox[0].extra_headers, {settings.EMAIL_HEADER_NAME: 'Translated'})
 
         # Testing if the role was activated


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]