From 60d66f0422b54ade06ac9d5ade89265354561c96 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 14 Mar 2019 16:15:55 +0100 Subject: [PATCH] [Fix #3064] Add logo and cancel link on preview --- .../new_administrateur/mail_templates_controller.rb | 3 ++- app/mailers/notification_mailer.rb | 5 +++-- app/views/layouts/mailers/notification.html.haml | 10 +++++++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/controllers/new_administrateur/mail_templates_controller.rb b/app/controllers/new_administrateur/mail_templates_controller.rb index 73d5ed18c..515b80435 100644 --- a/app/controllers/new_administrateur/mail_templates_controller.rb +++ b/app/controllers/new_administrateur/mail_templates_controller.rb @@ -4,8 +4,9 @@ module NewAdministrateur def preview @procedure = procedure - mail_template = find_mail_template_by_slug(params[:id]) @dossier = Dossier.new(id: 0) + mail_template = find_mail_template_by_slug(params[:id]) + @logo_url = procedure.logo.url render(html: sanitize(mail_template.body), layout: 'mailers/notification') end diff --git a/app/mailers/notification_mailer.rb b/app/mailers/notification_mailer.rb index 939cb9a88..aafa91665 100644 --- a/app/mailers/notification_mailer.rb +++ b/app/mailers/notification_mailer.rb @@ -39,8 +39,9 @@ class NotificationMailer < ApplicationMailer @dossier = dossier if dossier.procedure.logo? - @logo_filename = dossier.procedure.logo.filename - attachments.inline[@logo_filename] = dossier.procedure.logo.read + logo_filename = dossier.procedure.logo.filename + attachments.inline[logo_filename] = dossier.procedure.logo.read + @logo_url = attachments[logo_filename].url end mail(subject: subject, to: email) do |format| diff --git a/app/views/layouts/mailers/notification.html.haml b/app/views/layouts/mailers/notification.html.haml index 77cffee7a..89d3a5c29 100644 --- a/app/views/layouts/mailers/notification.html.haml +++ b/app/views/layouts/mailers/notification.html.haml @@ -1,14 +1,18 @@ -- if @logo_filename.present? +- if @logo_url.present? - content_for :procedure_logo do %table{ width: "100%", border: "0", cellspacing: "0", cellpadding: "0" } %tr %td{ align: "center" } - = image_tag attachments[@logo_filename].url, style: "height: 150px;" + = image_tag @logo_url, style: "height: 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_dossier_url(@dossier), target: '_blank', rel: 'noopener' + = link_to 'messagerie', messagerie_url, target: '_blank', rel: 'noopener' = render template: 'layouts/mailers/notifications_layout'