Merge pull request #4257 from tchak/fix-attestation-preview

Fix attestation preview
This commit is contained in:
Paul Chavard 2019-08-28 16:42:56 +02:00 committed by GitHub
commit 1a7b219478
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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)