From 37c93e634e8bc5aadbb2266a8501ff7b0137b848 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Wed, 17 Jul 2019 14:26:55 +0200 Subject: [PATCH 1/6] emails: clarify the `notify_new_draft` action --- app/views/dossier_mailer/notify_new_draft.html.haml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/views/dossier_mailer/notify_new_draft.html.haml b/app/views/dossier_mailer/notify_new_draft.html.haml index 94bc70119..9c3a63a9a 100644 --- a/app/views/dossier_mailer/notify_new_draft.html.haml +++ b/app/views/dossier_mailer/notify_new_draft.html.haml @@ -2,9 +2,12 @@ Bonjour, %p - Vous pouvez retrouver et compléter le brouillon que vous avez créé pour la démarche - %strong= @dossier.procedure.libelle - à l'adresse suivante : + Vous avez commencé à remplir un dossier pour la démarche « #{@dossier.procedure.libelle} ». + +%p + Vous pouvez + %strong retrouver et compléter votre dossier + à l’adresse suivante : = link_to dossier_url(@dossier), dossier_url(@dossier), target: '_blank', rel: 'noopener' = render partial: "layouts/mailers/signature" From b157d860d2f47f6223eb4ea531fc25e3ee89499b Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Wed, 17 Jul 2019 14:12:57 +0200 Subject: [PATCH 2/6] emails: adjust notification footer for dossiers without messagerie --- app/mailers/dossier_mailer.rb | 2 ++ .../layouts/mailers/notification.html.haml | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/mailers/dossier_mailer.rb b/app/mailers/dossier_mailer.rb index c07fed240..53b44f817 100644 --- a/app/mailers/dossier_mailer.rb +++ b/app/mailers/dossier_mailer.rb @@ -1,5 +1,7 @@ # Preview all emails at http://localhost:3000/rails/mailers/dossier_mailer class DossierMailer < ApplicationMailer + helper ServiceHelper + layout 'mailers/layout' def notify_new_draft(dossier) diff --git a/app/views/layouts/mailers/notification.html.haml b/app/views/layouts/mailers/notification.html.haml index b267a0fc5..1441f8508 100644 --- a/app/views/layouts/mailers/notification.html.haml +++ b/app/views/layouts/mailers/notification.html.haml @@ -6,14 +6,12 @@ = image_tag @logo_url, height: "150", style: "display:block; max-height: 150px; max-width: 150px;" - content_for :footer do - - if @dossier.present? - - messagerie_url = messagerie_dossier_url(@dossier) - - else - - messagerie_url = "#" %strong - Merci de ne pas répondre à cet email. Pour vous adresser à votre administration, passez directement par votre - = succeed '.' do - = link_to 'messagerie', messagerie_url, target: '_blank', rel: 'noopener' + Merci de ne pas répondre à cet email. + - if @dossier.present? && @dossier.messagerie_available? + Pour vous adresser à votre administration, passez directement par votre + = succeed '.' do + = link_to 'messagerie', messagerie_dossier_url(@dossier), target: '_blank', rel: 'noopener' - if @service.present? %table{ width: "100%", border: "0", cellspacing: "0", cellpadding: "0", style: "cursor:auto;color:#55575d;font-family:Helvetica, Arial, sans-serif;font-size:11px;line-height:22px;text-align:left;" } @@ -31,7 +29,11 @@ %p %strong Poser une question sur votre dossier : %br - = link_to 'Par la messagerie', messagerie_url, target: '_blank', rel: 'noopener' + - if @dossier.present? && @dossier.messagerie_available? + = link_to 'Par la messagerie', messagerie_dossier_url(@dossier), target: '_blank', rel: 'noopener' + - else + Par email : + = link_to @service.email, "mailto:#{@service.email}" %br Par téléphone : = link_to @service.telephone, "tel:#{@service.telephone}" From 8b80c486792e04b5a21fcf94f4cd25b1dc9ca540 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Wed, 17 Jul 2019 12:41:37 +0000 Subject: [PATCH 3/6] emails: use the notification template for more messages This allow to display the procedure logo and contact footer at the bottom of these emails. --- app/mailers/application_mailer.rb | 18 ++++++++++++++++++ app/mailers/dossier_mailer.rb | 10 +++++++++- app/mailers/notification_mailer.rb | 13 +------------ 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index a2612765e..88f1a3353 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -2,4 +2,22 @@ class ApplicationMailer < ActionMailer::Base helper :application # gives access to all helpers defined within `application_helper`. default from: "demarches-simplifiees.fr <#{CONTACT_EMAIL}>" layout 'mailer' + + # Attach the procedure logo to the email (if any). + # Returns the attachment url. + def attach_logo(procedure) + return nil if !procedure.logo? + + begin + logo_filename = procedure.logo.filename + attachments.inline[logo_filename] = procedure.logo.read + attachments[logo_filename].url + + rescue StandardError => e + # A problem occured when reading logo, maybe the logo is missing and we should clean the procedure to remove logo reference ? + Raven.extra_context(procedure_id: procedure.id) + Raven.capture_exception(e) + nil + end + end end diff --git a/app/mailers/dossier_mailer.rb b/app/mailers/dossier_mailer.rb index 53b44f817..8483fde87 100644 --- a/app/mailers/dossier_mailer.rb +++ b/app/mailers/dossier_mailer.rb @@ -6,13 +6,21 @@ class DossierMailer < ApplicationMailer def notify_new_draft(dossier) @dossier = dossier + @service = dossier.procedure.service + @logo_url = attach_logo(dossier.procedure) + subject = "Retrouvez votre brouillon pour la démarche « #{dossier.procedure.libelle} »" - mail(to: dossier.user.email, subject: subject) + mail(to: dossier.user.email, subject: subject) do |format| + format.html { render layout: 'mailers/notification' } + end end def notify_new_answer(dossier) @dossier = dossier + @service = dossier.procedure.service + @logo_url = attach_logo(dossier.procedure) + subject = "Nouveau message pour votre dossier nº #{dossier.id} (#{dossier.procedure.libelle})" mail(to: dossier.user.email, subject: subject) do |format| diff --git a/app/mailers/notification_mailer.rb b/app/mailers/notification_mailer.rb index 2822d405a..87379f6df 100644 --- a/app/mailers/notification_mailer.rb +++ b/app/mailers/notification_mailer.rb @@ -38,20 +38,9 @@ class NotificationMailer < ApplicationMailer create_commentaire_for_notification(dossier, subject, body) - if dossier.procedure.logo? - begin - logo_filename = dossier.procedure.logo.filename - attachments.inline[logo_filename] = dossier.procedure.logo.read - @logo_url = attachments[logo_filename].url - rescue StandardError => e - # A problem occured when reading logo, maybe the logo is missing and we should clean the procedure to remove logo reference ? - Raven.extra_context(procedure_id: dossier.procedure.id) - Raven.capture_exception(e) - end - end - @dossier = dossier @service = dossier.procedure.service + @logo_url = attach_logo(dossier.procedure) mail(subject: subject, to: email) do |format| # rubocop:disable Rails/OutputSafety From 630ae065427dc1ceaeb9b737b1e266342d84149d Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Wed, 17 Jul 2019 14:36:46 +0000 Subject: [PATCH 4/6] emails: sign the new answer email as the administration --- app/views/dossier_mailer/notify_new_answer.html.haml | 2 +- app/views/layouts/mailers/_signature.html.haml | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/views/dossier_mailer/notify_new_answer.html.haml b/app/views/dossier_mailer/notify_new_answer.html.haml index 1dac34790..6a1bd4f33 100644 --- a/app/views/dossier_mailer/notify_new_answer.html.haml +++ b/app/views/dossier_mailer/notify_new_answer.html.haml @@ -8,4 +8,4 @@ Pour le consulter, merci de vous rendre sur = link_to messagerie_dossier_url(@dossier), messagerie_dossier_url(@dossier), target: '_blank', rel:'noopener' -= render partial: "layouts/mailers/signature" += render partial: "layouts/mailers/signature", locals: { service: @service } diff --git a/app/views/layouts/mailers/_signature.html.haml b/app/views/layouts/mailers/_signature.html.haml index ca5ad2778..f425b70be 100644 --- a/app/views/layouts/mailers/_signature.html.haml +++ b/app/views/layouts/mailers/_signature.html.haml @@ -1,4 +1,7 @@ %p Bonne journée, %br - L’équipe demarches-simplifiees.fr + - if defined?(service) && service && service.nom.present? + = service.nom + - else + L’équipe demarches-simplifiees.fr From f88d7c28fadfbe63be3f0eae314581664b276c7e Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Wed, 17 Jul 2019 16:42:34 +0200 Subject: [PATCH 5/6] emails: add a "Read message" button to the new answer email --- app/helpers/mailer_helper.rb | 5 +++++ app/mailers/dossier_mailer.rb | 1 + app/views/dossier_mailer/notify_new_answer.html.haml | 8 +++++--- app/views/shared/_mailer_round_button.html.haml | 9 +++++++++ 4 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 app/helpers/mailer_helper.rb create mode 100644 app/views/shared/_mailer_round_button.html.haml diff --git a/app/helpers/mailer_helper.rb b/app/helpers/mailer_helper.rb new file mode 100644 index 000000000..28767841d --- /dev/null +++ b/app/helpers/mailer_helper.rb @@ -0,0 +1,5 @@ +module MailerHelper + def round_button(text, url) + render 'shared/mailer_round_button', text: text, url: url + end +end diff --git a/app/mailers/dossier_mailer.rb b/app/mailers/dossier_mailer.rb index 8483fde87..613b64775 100644 --- a/app/mailers/dossier_mailer.rb +++ b/app/mailers/dossier_mailer.rb @@ -1,6 +1,7 @@ # Preview all emails at http://localhost:3000/rails/mailers/dossier_mailer class DossierMailer < ApplicationMailer helper ServiceHelper + helper MailerHelper layout 'mailers/layout' diff --git a/app/views/dossier_mailer/notify_new_answer.html.haml b/app/views/dossier_mailer/notify_new_answer.html.haml index 6a1bd4f33..502b5a985 100644 --- a/app/views/dossier_mailer/notify_new_answer.html.haml +++ b/app/views/dossier_mailer/notify_new_answer.html.haml @@ -2,10 +2,12 @@ Bonjour, %p - Un nouveau message est disponible dans votre espace demarches-simplifiees.fr. + L’administration en charge de votre dossier vous a + %strong envoyé un nouveau message. %p - Pour le consulter, merci de vous rendre sur - = link_to messagerie_dossier_url(@dossier), messagerie_dossier_url(@dossier), target: '_blank', rel:'noopener' + Pour le consulter et y répondre, cliquez sur le bouton ci-dessous : + += round_button('Lire le message', messagerie_dossier_url(@dossier)) = render partial: "layouts/mailers/signature", locals: { service: @service } diff --git a/app/views/shared/_mailer_round_button.html.haml b/app/views/shared/_mailer_round_button.html.haml new file mode 100644 index 000000000..18031f176 --- /dev/null +++ b/app/views/shared/_mailer_round_button.html.haml @@ -0,0 +1,9 @@ +/# From https://litmus.com/blog/a-guide-to-bulletproof-buttons-in-email-design +%table{ width: "100%", border: "0", cellspacing:"0", cellpadding:"0" } + %tr + %td + %table{ border:"0", cellspacing:"0", cellpadding:"0", style:"margin: auto" } + %tr + %td{ align:"center", style:"border-radius: 5px;", bgcolor:"#0069cc" } + %a{ href: url, target:"_blank", style:"font-size: 16px; font-family: Helvetica, Arial, sans-serif; color: #ffffff; text-decoration: none; text-decoration: none; border-radius: 5px; padding: 12px 25px; border: 1px solid #0069cc; display: inline-block;" } + = text From 3c0ba5e6987ab845ec97b8e344de3dbaf83048f4 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Wed, 17 Jul 2019 16:49:40 +0200 Subject: [PATCH 6/6] emails: improve wording of the messagerie nudge --- app/views/layouts/mailers/notification.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/layouts/mailers/notification.html.haml b/app/views/layouts/mailers/notification.html.haml index 1441f8508..04da35e63 100644 --- a/app/views/layouts/mailers/notification.html.haml +++ b/app/views/layouts/mailers/notification.html.haml @@ -9,9 +9,9 @@ %strong Merci de ne pas répondre à cet email. - if @dossier.present? && @dossier.messagerie_available? - Pour vous adresser à votre administration, passez directement par votre + Pour vous adresser à votre administration, passez directement par la = succeed '.' do - = link_to 'messagerie', messagerie_dossier_url(@dossier), target: '_blank', rel: 'noopener' + = link_to 'messagerie du dossier', messagerie_dossier_url(@dossier), target: '_blank', rel: 'noopener' - if @service.present? %table{ width: "100%", border: "0", cellspacing: "0", cellpadding: "0", style: "cursor:auto;color:#55575d;font-family:Helvetica, Arial, sans-serif;font-size:11px;line-height:22px;text-align:left;" }