Browse Source

fix template to allow easily to fix url bug directly from python code

Guénaël Muller 6 years ago
parent
commit
d3378ccff1

+ 34 - 20
tracim/lib/mail_notifier/notifier.py View File

@@ -357,22 +357,22 @@ class EmailManager(object):
357 357
         text_template_file_path = self.config.EMAIL_NOTIFICATION_CREATED_ACCOUNT_TEMPLATE_TEXT  # nopep8
358 358
         html_template_file_path = self.config.EMAIL_NOTIFICATION_CREATED_ACCOUNT_TEMPLATE_HTML  # nopep8
359 359
 
360
+        context = {
361
+            'user': user,
362
+            'password': password,
363
+            # TODO - G.M - 11-06-2018 - [emailTemplateURL] correct value for logo_url  # nopep8
364
+            'logo_url': '',
365
+            # TODO - G.M - 11-06-2018 - [emailTemplateURL] correct value for login_url  # nopep8
366
+            'login_url': self.config.WEBSITE_BASE_URL,
367
+        }
360 368
         body_text = self._render_template(
361 369
             mako_template_filepath=text_template_file_path,
362
-            context={
363
-                'user': user,
364
-                'password': password,
365
-                'login_url': self.config.WEBSITE_BASE_URL,
366
-            }
370
+            context=context
367 371
         )
368 372
 
369 373
         body_html = self._render_template(
370 374
             mako_template_filepath=html_template_file_path,
371
-            context={
372
-                'user': user,
373
-                'password': password,
374
-                'login_url': self.config.WEBSITE_BASE_URL,
375
-            }
375
+            context=context,
376 376
         )
377 377
 
378 378
         part1 = MIMEText(body_text, 'plain', 'utf-8')
@@ -433,6 +433,15 @@ class EmailManager(object):
433 433
         content_text = ''
434 434
         call_to_action_text = ''
435 435
 
436
+        # TODO - G.M - 11-06-2018 - [emailTemplateURL] correct value for call_to_action_url  # nopep8
437
+        call_to_action_url =''
438
+        # TODO - G.M - 11-06-2018 - [emailTemplateURL] correct value for status_icon_url  # nopep8
439
+        status_icon_url = ''
440
+        # TODO - G.M - 11-06-2018 - [emailTemplateURL] correct value for workspace_url  # nopep8
441
+        workspace_url = ''
442
+        # TODO - G.M - 11-06-2018 - [emailTemplateURL] correct value for logo_url  # nopep8
443
+        logo_url = ''
444
+
436 445
         action = content.get_last_action().id
437 446
         if ActionDescription.COMMENT == action:
438 447
             content_intro = l_('<span id="content-intro-username">{}</span> added a comment:').format(actor.display_name)
@@ -522,20 +531,25 @@ class EmailManager(object):
522 531
             )
523 532
             raise ValueError('Unexpected empty notification')
524 533
 
534
+        context = {
535
+            'user': role.user,
536
+            'workspace': role.workspace,
537
+            'workspace_url': workspace_url,
538
+            'main_title': main_title,
539
+            'status_label': content.get_status().label,
540
+            'status_icon_url': status_icon_url,
541
+            'role_label': role.role_as_label(),
542
+            'content_intro': content_intro,
543
+            'content_text': content_text,
544
+            'call_to_action_text': call_to_action_text,
545
+            'call_to_action_url': call_to_action_url,
546
+            'logo_url': logo_url,
547
+        }
525 548
         user = role.user
526 549
         workspace = role.workspace
527 550
         body_content = self._render_template(
528 551
             mako_template_filepath=mako_template_filepath,
529
-            context={
530
-                'user': role.user,
531
-                'workspace': role.workspace,
532
-                'main_title': main_title,
533
-                'status': content.get_status().label,
534
-                'role': role.role_as_label(),
535
-                'content_intro': content_intro,
536
-                'content_text': content_text,
537
-                'call_to_action_text': call_to_action_text,
538
-            }
552
+            context=context,
539 553
         )
540 554
         return body_content
541 555
 

+ 5 - 6
tracim/templates/mail/content_update_body_html.mak View File

@@ -38,14 +38,14 @@
38 38
     <table style="width: 100%; cell-padding: 0; border-collapse: collapse; margin: 0">
39 39
       <tr style="background-color: F5F5F5; border-bottom: 1px solid #CCC;" >
40 40
         <td style="background-color: #666;">
41
-            <!-- FIXME - G.M - 09-06-2018 - restore logo -->
41
+            <img alt="logo" src="${logo_url}" style="vertical-align: middle;">
42 42
         </td>
43 43
         <td style="padding: 0.5em; background-color: #666; text-align: left;">
44 44
           <span style="font-size: 1.3em; color: #FFF; font-weight: bold;">
45 45
             ${main_title}
46 46
             &mdash;&nbsp;<span style="font-weight: bold; color: #999; font-weight: bold;">
47
-              ${status|n}
48
-              <!-- FIXME - G.M - 09-06-2018 - restore icon -->
47
+              ${status_label|n}
48
+              <img alt="status_icon" src="${status_icon_url}" style="vertical-align: middle;">
49 49
             </span>
50 50
         </td>
51 51
       </tr>
@@ -54,15 +54,14 @@
54 54
     <p id="content-intro">${content_intro|n}</p>
55 55
     <div id="content-body">
56 56
         <div>${content_text|n}</div>
57
-        <!-- FIXME - G.M - 09-06-2018 - fix action url -->
58 57
         <div href='' id="call-to-action-container">
59 58
         </div>
60 59
     </div>
61 60
     
62 61
     <div id="footer">
63 62
         <p>
64
-            <!-- FIXME - G.M - 09-06-2018 - Set correct workspace url -->
65
-            ${_('{user_display_name}, you receive this email because you are registered on <i>{website_title}</i> and you are <i>{user_role_label}</i> in the workspace <a href="{workspace_url}">{workspace_label}</a>.').format(user_display_name=user.display_name, user_role_label=role, workspace_url='', workspace_label=workspace.label, website_title=config.WEBSITE_TITLE)|n}
63
+
64
+            ${_('{user_display_name}, you receive this email because you are registered on <i>{website_title}</i> and you are <i>{user_role_label}</i> in the workspace <a href="{workspace_url}">{workspace_label}</a>.').format(user_display_name=user.display_name, user_role_label=role_label, workspace_url=workspace_url, workspace_label=workspace.label, website_title=config.WEBSITE_TITLE)|n}
66 65
         </p>
67 66
         <hr/>
68 67
         <p>

+ 1 - 1
tracim/templates/mail/content_update_body_text.mak View File

@@ -16,7 +16,7 @@ Hope you'll switch your mail client configuration and enjoy Tracim :)
16 16
 
17 17
 
18 18
 You receive this email because you are registered on /${config.WEBSITE_TITLE}/
19
-and you are /${role}/ in the workspace /${workspace.label}/
19
+and you are /${role_label}/ in the workspace /${workspace.label}/
20 20
 
21 21
 ----
22 22
 

+ 1 - 1
tracim/templates/mail/created_account_body_html.mak View File

@@ -38,7 +38,7 @@
38 38
     <table style="width: 100%; cell-padding: 0; border-collapse: collapse; margin: 0">
39 39
       <tr style="background-color: F5F5F5; border-bottom: 1px solid #CCC;" >
40 40
         <td style="background-color: #666;">
41
-            <!-- FIXME - G.M - 09-06-2018 - restore logo -->
41
+            <img alt="logo" src="${logo_url}" style="vertical-align: middle;">
42 42
         </td>
43 43
         <td style="padding: 0.5em; background-color: #666; text-align: left;">
44 44
           <span style="font-size: 1.3em; color: #FFF; font-weight: bold;">