Fix attestation preview

This commit is contained in:
Paul Chavard 2019-08-28 16:33:51 +02:00
parent 1999b4d86b
commit 3c6b35d720
2 changed files with 12 additions and 4 deletions

View file

@ -22,8 +22,8 @@ module Instructeurs
end
def apercu_attestation
@title = dossier.procedure.attestation_template.title
@body = dossier.procedure.attestation_template.body
@title = dossier.procedure.attestation_template.title_for_dossier(dossier)
@body = dossier.procedure.attestation_template.body_for_dossier(dossier)
@footer = dossier.procedure.attestation_template.footer
@created_at = Time.zone.now
@logo = dossier.procedure.attestation_template&.proxy_logo

View file

@ -122,6 +122,14 @@ class AttestationTemplate < ApplicationRecord
end
end
def title_for_dossier(dossier)
replace_tags(title, dossier)
end
def body_for_dossier(dossier)
replace_tags(body, dossier)
end
private
def used_tags
@ -138,8 +146,8 @@ class AttestationTemplate < ApplicationRecord
def build_pdf(dossier)
action_view = ActionView::Base.new(ActionController::Base.view_paths,
logo: proxy_logo,
title: replace_tags(title, dossier),
body: replace_tags(body, dossier),
title: title_for_dossier(dossier),
body: body_for_dossier(dossier),
signature: proxy_signature,
footer: footer,
created_at: Time.zone.now)