Migrate attestation files to active_storage
This commit is contained in:
parent
a194ffa392
commit
a19b10b118
11 changed files with 289 additions and 96 deletions
|
@ -17,11 +17,11 @@
|
|||
celle-ci est également disponible au téléchargement depuis l’espace personnel de l’usager.
|
||||
|
||||
.image-upload
|
||||
- if @attestation_template.logo.present?
|
||||
= image_tag @attestation_template.logo.url, class: 'thumbnail'
|
||||
- if @attestation_template.logo?
|
||||
= image_tag @attestation_template.logo_url, class: 'thumbnail'
|
||||
.form-group
|
||||
= f.label :logo, "Logo de l'attestation"
|
||||
- if @attestation_template.logo.present?
|
||||
- if @attestation_template.logo?
|
||||
= link_to 'Supprimer le logo', admin_procedure_attestation_template_logo_path(@procedure), method: :delete
|
||||
= f.file_field :logo, accept: 'image/png, image/jpg, image/jpeg'
|
||||
%p.help-block
|
||||
|
@ -54,11 +54,11 @@
|
|||
= tag[:description]
|
||||
|
||||
.image-upload
|
||||
- if @attestation_template.signature.present?
|
||||
= image_tag @attestation_template.signature.url, class: 'thumbnail'
|
||||
- if @attestation_template.signature?
|
||||
= image_tag @attestation_template.signature_url, class: 'thumbnail'
|
||||
.form-group
|
||||
= f.label :signature, "Tampon de l'attestation"
|
||||
- if @attestation_template.signature.present?
|
||||
- if @attestation_template.signature?
|
||||
= link_to 'Supprimer le tampon', admin_procedure_attestation_template_signature_path(@procedure), method: :delete
|
||||
= f.file_field :signature, accept: 'image/png, image/jpg, image/jpeg'
|
||||
%p.help-block
|
||||
|
|
|
@ -30,7 +30,12 @@ prawn_document(margin: [top_margin, right_margin, bottom_margin, left_margin], p
|
|||
|
||||
pdf.bounding_box([0, pdf.cursor], width: body_width, height: body_height) do
|
||||
if @logo.present?
|
||||
pdf.image StringIO.new(@logo.read), fit: [max_logo_width , max_logo_height], position: :center
|
||||
logo_file = if @logo.is_a?(ActiveStorage::Attached::One)
|
||||
@logo.download
|
||||
else
|
||||
@logo.read
|
||||
end
|
||||
pdf.image StringIO.new(logo_file), fit: [max_logo_width , max_logo_height], position: :center
|
||||
end
|
||||
|
||||
pdf.fill_color grey
|
||||
|
@ -44,7 +49,12 @@ prawn_document(margin: [top_margin, right_margin, bottom_margin, left_margin], p
|
|||
|
||||
if @signature.present?
|
||||
pdf.pad_top(40) do
|
||||
pdf.image StringIO.new(@signature.read), fit: [max_signature_size , max_signature_size], position: :right
|
||||
signature_file = if @signature.is_a?(ActiveStorage::Attached::One)
|
||||
@signature.download
|
||||
else
|
||||
@signature.read
|
||||
end
|
||||
pdf.image StringIO.new(signature_file), fit: [max_signature_size , max_signature_size], position: :right
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue