Browse Source

Replace email.notification.from config

Bastien Sevajol (Algoo) 8 years ago
parent
commit
4c8eea3b31

+ 2 - 1
README.md View File

318
 The main parameters for notifications are the following ones:
318
 The main parameters for notifications are the following ones:
319
 
319
 
320
     email.notification.activated = true
320
     email.notification.activated = true
321
-    email.notification.from = Tracim Notification <tracim@tmycompany.com>
321
+    email.notification.from.email = noreply@trac.im
322
+    email.notification.from.default_label = Tracim Notification
322
     email.notification.smtp.server = smtp.mycompany.com
323
     email.notification.smtp.server = smtp.mycompany.com
323
     email.notification.smtp.port = 25
324
     email.notification.smtp.port = 25
324
     email.notification.smtp.user = username
325
     email.notification.smtp.user = username

+ 2 - 1
tracim/development.ini.base View File

176
 website.server_name = 127.0.0.1
176
 website.server_name = 127.0.0.1
177
     
177
     
178
 email.notification.activated = False
178
 email.notification.activated = False
179
-email.notification.from = Tracim Notification <noreply@trac.im>
179
+email.notification.from.email = noreply@trac.im
180
+email.notification.from.default_label = Tracim Notifications
180
 email.notification.content_update.template.html = ./tracim/templates/mail/content_update_body_html.mak
181
 email.notification.content_update.template.html = ./tracim/templates/mail/content_update_body_html.mak
181
 email.notification.content_update.template.text = ./tracim/templates/mail/content_update_body_text.mak
182
 email.notification.content_update.template.text = ./tracim/templates/mail/content_update_body_text.mak
182
 email.notification.created_account.template.html = ./tracim/templates/mail/created_account_body_html.mak
183
 email.notification.created_account.template.html = ./tracim/templates/mail/created_account_body_html.mak

+ 10 - 1
tracim/tracim/config/app_cfg.py View File

202
         self.WEBSITE_SUBTITLE = tg.config.get('website.home.subtitle', '')
202
         self.WEBSITE_SUBTITLE = tg.config.get('website.home.subtitle', '')
203
         self.WEBSITE_HOME_BELOW_LOGIN_FORM = tg.config.get('website.home.below_login_form', '')
203
         self.WEBSITE_HOME_BELOW_LOGIN_FORM = tg.config.get('website.home.below_login_form', '')
204
 
204
 
205
+        if tg.config.get('email.notification.from'):
206
+            raise Exception(
207
+                'email.notification.from configuration is deprecated. '
208
+                'Use instead email.notification.from.email and '
209
+                'email.notification.from.default_label.'
210
+            )
205
 
211
 
206
-        self.EMAIL_NOTIFICATION_FROM = tg.config.get('email.notification.from')
212
+        self.EMAIL_NOTIFICATION_FROM_EMAIL = \
213
+            tg.config.get('email.notification.from.email')
214
+        self.EMAIL_NOTIFICATION_FROM_DEFAULT_LABEL = \
215
+            tg.config.get('email.notification.from.default_label')
207
         self.EMAIL_NOTIFICATION_CONTENT_UPDATE_TEMPLATE_HTML = tg.config.get('email.notification.content_update.template.html')
216
         self.EMAIL_NOTIFICATION_CONTENT_UPDATE_TEMPLATE_HTML = tg.config.get('email.notification.content_update.template.html')
208
         self.EMAIL_NOTIFICATION_CONTENT_UPDATE_TEMPLATE_TEXT = tg.config.get('email.notification.content_update.template.text')
217
         self.EMAIL_NOTIFICATION_CONTENT_UPDATE_TEMPLATE_TEXT = tg.config.get('email.notification.content_update.template.text')
209
         self.EMAIL_NOTIFICATION_CREATED_ACCOUNT_TEMPLATE_HTML = tg.config.get(
218
         self.EMAIL_NOTIFICATION_CREATED_ACCOUNT_TEMPLATE_HTML = tg.config.get(

+ 4 - 1
tracim/tracim/lib/email.py View File

103
             )
103
             )
104
         message = MIMEMultipart('alternative')
104
         message = MIMEMultipart('alternative')
105
         message['Subject'] = subject
105
         message['Subject'] = subject
106
-        message['From'] = self._global_config.EMAIL_NOTIFICATION_FROM
106
+        message['From'] = '{0} <{1}>'.format(
107
+            self._global_config.EMAIL_NOTIFICATION_FROM_DEFAULT_LABEL,
108
+            self._global_config.EMAIL_NOTIFICATION_FROM_EMAIL,
109
+        )
107
         message['To'] = user.email
110
         message['To'] = user.email
108
 
111
 
109
         text_template_file_path = self._global_config.EMAIL_NOTIFICATION_CREATED_ACCOUNT_TEMPLATE_TEXT  # nopep8
112
         text_template_file_path = self._global_config.EMAIL_NOTIFICATION_CREATED_ACCOUNT_TEMPLATE_TEXT  # nopep8

+ 4 - 1
tracim/tracim/lib/notifications.py View File

233
 
233
 
234
             message = MIMEMultipart('alternative')
234
             message = MIMEMultipart('alternative')
235
             message['Subject'] = subject
235
             message['Subject'] = subject
236
-            message['From'] = self._global_config.EMAIL_NOTIFICATION_FROM
236
+            message['From'] = '{0} <{1}>'.format(
237
+                self._global_config.EMAIL_NOTIFICATION_FROM_DEFAULT_LABEL,
238
+                self._global_config.EMAIL_NOTIFICATION_FROM_EMAIL,
239
+            )
237
             message['To'] = to_addr
240
             message['To'] = to_addr
238
 
241
 
239
             body_text = self._build_email_body(self._global_config.EMAIL_NOTIFICATION_CONTENT_UPDATE_TEMPLATE_TEXT, role, content, user)
242
             body_text = self._build_email_body(self._global_config.EMAIL_NOTIFICATION_CONTENT_UPDATE_TEMPLATE_TEXT, role, content, user)