diff --git a/app/controllers/administrateurs/attestation_template_v2s_controller.rb b/app/controllers/administrateurs/attestation_template_v2s_controller.rb index e44198380..6447097e2 100644 --- a/app/controllers/administrateurs/attestation_template_v2s_controller.rb +++ b/app/controllers/administrateurs/attestation_template_v2s_controller.rb @@ -10,7 +10,8 @@ module Administrateurs def show preview_dossier = @procedure.dossier_for_preview(current_user) - @body = @attestation_template.render_attributes_for(dossier: preview_dossier).fetch(:body) + @body = attributes.fetch(:body) + @signature = attributes.fetch(:signature) respond_to do |format| format.html do diff --git a/app/models/attestation_template.rb b/app/models/attestation_template.rb index c6de7340a..82207cb23 100644 --- a/app/models/attestation_template.rb +++ b/app/models/attestation_template.rb @@ -111,12 +111,6 @@ class AttestationTemplate < ApplicationRecord end end - def signature_url - if signature.attached? - Rails.application.routes.url_helpers.url_for(signature) - end - end - def render_attributes_for(params = {}) groupe_instructeur = params[:groupe_instructeur] groupe_instructeur ||= params[:dossier]&.groupe_instructeur @@ -176,13 +170,11 @@ class AttestationTemplate < ApplicationRecord substitutions = tags_substitutions(used_tags, dossier, escape: false) body = tiptap.to_html(json, substitutions) - attributes.merge( - body: - ) + attributes.merge(body:).merge(base_attributes) else attributes.merge( body: params.fetch(:body) { tiptap.to_html(json) } - ) + ).merge(base_attributes) end end diff --git a/app/views/administrateurs/attestation_template_v2s/show.html.haml b/app/views/administrateurs/attestation_template_v2s/show.html.haml index 0d09469e7..3351d889f 100644 --- a/app/views/administrateurs/attestation_template_v2s/show.html.haml +++ b/app/views/administrateurs/attestation_template_v2s/show.html.haml @@ -26,6 +26,6 @@ .main = sanitize(@body, attributes: %w[class style], tags: Rails.configuration.action_view.sanitized_allowed_tags + %w[header]) - - if @attestation_template.signature.present? + - if @signature&.attached? .signature - = image_tag(@attestation_template.signature_url) + = image_tag(@signature)