From 433c01b1e6a951a92ce688ce0d26c7cd0cc3c259 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Tue, 12 Apr 2022 19:20:50 +0200 Subject: [PATCH] Revert "Merge pull request #7137 from betagouv/faster_pdf" This reverts commit 9da44bd913b8400c9c90de506f375607d67340d4, reversing changes made to ebac71796caf2ecd9ec76e42614e045838179b4a. --- Gemfile | 1 + Gemfile.lock | 4 ++ app/assets/images/header/logo-ds-wide.png | Bin 18553 -> 0 bytes app/lib/active_storage/downloadable_file.rb | 5 +- app/models/dossier.rb | 5 +- app/services/pieces_justificatives_service.rb | 51 +++++------------- app/views/dossiers/dossier_vide.pdf.prawn | 2 +- app/views/dossiers/show.pdf.prawn | 23 ++++---- config/env.example.optional | 2 +- config/initializers/images.rb | 2 +- .../pieces_justificatives_service_spec.rb | 2 +- 11 files changed, 37 insertions(+), 60 deletions(-) delete mode 100644 app/assets/images/header/logo-ds-wide.png diff --git a/Gemfile b/Gemfile index 24f8c36c9..e210be466 100644 --- a/Gemfile +++ b/Gemfile @@ -59,6 +59,7 @@ gem 'openid_connect' gem 'pg' gem 'phonelib' gem 'prawn-rails' # PDF Generation +gem 'prawn-svg' gem 'premailer-rails' gem 'puma' # Use Puma as the app server gem 'pundit' diff --git a/Gemfile.lock b/Gemfile.lock index 0faaa9859..4485809aa 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -459,6 +459,9 @@ GEM prawn prawn-table rails (>= 3.1.0) + prawn-svg (0.31.0) + css_parser (~> 1.6) + prawn (>= 0.11.1, < 3) prawn-table (0.2.2) prawn (>= 1.3.0, < 3.0.0) premailer (1.14.2) @@ -837,6 +840,7 @@ DEPENDENCIES pg phonelib prawn-rails + prawn-svg premailer-rails pry-byebug puma diff --git a/app/assets/images/header/logo-ds-wide.png b/app/assets/images/header/logo-ds-wide.png deleted file mode 100644 index a0ac0f35319574a377870e6f6150bf2d21b2e8d9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 18553 zc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(; z7Eb4o=XA+%H0}cym-WEGnjf6)br1C?d~od+YxOnS#HxAJtYFUqeRB`s7(jG|NYQU# z+gN~&b^kA5GqU>23&yiTvZtGnB&Gw<8&pyj)xNzoq=;j-FM{7awKFV zE>4S|;lQU{ow&q9^OOAw9pEAZ{^xfqt_g%JDS~unIXcZW>)a3cCzt~J@YcYo4Pfo} z=iTo2r#>$AWPKtQR1RFN=dvjhqS#~6q$^Gu62Q(Cu+yQbRbP0l+XkK6+(>I diff --git a/app/lib/active_storage/downloadable_file.rb b/app/lib/active_storage/downloadable_file.rb index ac1cb2a8d..3f38007be 100644 --- a/app/lib/active_storage/downloadable_file.rb +++ b/app/lib/active_storage/downloadable_file.rb @@ -1,7 +1,8 @@ class ActiveStorage::DownloadableFile def self.create_list_from_dossiers(dossiers, for_expert = false) - PiecesJustificativesService.generate_dossier_export(dossiers) + - PiecesJustificativesService.liste_documents(dossiers, for_expert) + dossiers + .map { |d| pj_and_path(d.id, PiecesJustificativesService.generate_dossier_export(d)) } + + PiecesJustificativesService.liste_documents(dossiers, for_expert) end private diff --git a/app/models/dossier.rb b/app/models/dossier.rb index aa18b21d0..e32aa99db 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -485,9 +485,8 @@ class Dossier < ApplicationRecord end def motivation - if termine? - traitement&.motivation || read_attribute(:motivation) - end + return nil if !termine? + traitement&.motivation || read_attribute(:motivation) end def update_search_terms diff --git a/app/services/pieces_justificatives_service.rb b/app/services/pieces_justificatives_service.rb index 7b8472563..aec2c0378 100644 --- a/app/services/pieces_justificatives_service.rb +++ b/app/services/pieces_justificatives_service.rb @@ -107,44 +107,21 @@ class PiecesJustificativesService end end - def self.generate_dossier_export(dossiers) - return [] if dossiers.empty? + def self.generate_dossier_export(dossier) + pdf = ApplicationController + .render(template: 'dossiers/show', formats: [:pdf], + assigns: { + include_infos_administration: true, + dossier: dossier + }) - pdfs = [] - - procedure = dossiers.first.procedure - tdc_by_id = TypeDeChamp - .joins(:revisions) - .where(revisions: { id: procedure.revisions }) - .to_a - .group_by(&:id) - - dossiers - .includes(:champs, :champs_private, :commentaires, :individual, - :traitement, :etablissement, - user: :france_connect_information, avis: :expert) - .find_each do |dossier| - pdf = ApplicationController - .render(template: 'dossiers/show', formats: [:pdf], - assigns: { - include_infos_administration: true, - dossier: dossier, - procedure: procedure, - tdc_by_id: tdc_by_id - }) - - a = FakeAttachment.new( - file: StringIO.new(pdf), - filename: "export-#{dossier.id}.pdf", - name: 'pdf_export_for_instructeur', - id: dossier.id, - created_at: dossier.updated_at - ) - - pdfs << ActiveStorage::DownloadableFile.pj_and_path(dossier.id, a) - end - - pdfs + FakeAttachment.new( + file: StringIO.new(pdf), + filename: "export-#{dossier.id}.pdf", + name: 'pdf_export_for_instructeur', + id: dossier.id, + created_at: dossier.updated_at + ) end private diff --git a/app/views/dossiers/dossier_vide.pdf.prawn b/app/views/dossiers/dossier_vide.pdf.prawn index f941d0537..5678ee1b0 100644 --- a/app/views/dossiers/dossier_vide.pdf.prawn +++ b/app/views/dossiers/dossier_vide.pdf.prawn @@ -181,7 +181,7 @@ prawn_document(page_size: "A4") do |pdf| italic: Rails.root.join('lib/prawn/fonts/marianne/marianne-thin.ttf' ), }) pdf.font 'marianne' - pdf.image DOSSIER_PDF_EXPORT_LOGO_SRC, width: 300, position: :center + pdf.svg IO.read(DOSSIER_PDF_EXPORT_LOGO_SRC), width: 300, position: :center pdf.move_down(40) render_in_2_columns(pdf, 'Démarche', @dossier.procedure.libelle) diff --git a/app/views/dossiers/show.pdf.prawn b/app/views/dossiers/show.pdf.prawn index 182d60fc0..b3b86eba6 100644 --- a/app/views/dossiers/show.pdf.prawn +++ b/app/views/dossiers/show.pdf.prawn @@ -130,30 +130,28 @@ def add_identite_etablissement(pdf, etablissement) end def add_single_champ(pdf, champ) - tdc = @tdc_by_id[champ.type_de_champ_id].first - case champ.type when 'Champs::PieceJustificativeChamp', 'Champs::TitreIdentiteChamp' return when 'Champs::HeaderSectionChamp' - add_section_title(pdf, tdc.libelle) + add_section_title(pdf, champ.libelle) when 'Champs::ExplicationChamp' - format_in_2_lines(pdf, tdc.libelle, tdc.description) + format_in_2_lines(pdf, champ.libelle, champ.description) when 'Champs::CarteChamp' - format_in_2_lines(pdf, tdc.libelle, champ.to_feature_collection.to_json) + format_in_2_lines(pdf, champ.libelle, champ.to_feature_collection.to_json) when 'Champs::SiretChamp' pdf.font 'marianne', style: :bold do - pdf.text tdc.libelle + pdf.text champ.libelle end if champ.etablissement.present? add_identite_etablissement(pdf, champ.etablissement) end when 'Champs::NumberChamp' value = champ.to_s.empty? ? 'Non communiqué' : number_with_delimiter(champ.to_s) - format_in_2_lines(pdf, tdc.libelle, value) + format_in_2_lines(pdf, champ.libelle, value) else value = champ.to_s.empty? ? 'Non communiqué' : champ.to_s - format_in_2_lines(pdf, tdc.libelle, value) + format_in_2_lines(pdf, champ.libelle, value) end end @@ -207,9 +205,6 @@ def add_etats_dossier(pdf, dossier) end prawn_document(page_size: "A4") do |pdf| - @procedure ||= @dossier.procedure - @tdc_by_id ||= @dossier.champs.map(&:type_de_champ).group_by(&:id) - pdf.font_families.update( 'marianne' => { normal: Rails.root.join('lib/prawn/fonts/marianne/marianne-regular.ttf' ), bold: Rails.root.join('lib/prawn/fonts/marianne/marianne-bold.ttf' ), @@ -217,12 +212,12 @@ prawn_document(page_size: "A4") do |pdf| pdf.font 'marianne' pdf.pad_bottom(40) do - pdf.image DOSSIER_PDF_EXPORT_LOGO_SRC, width: 300, position: :center + pdf.svg IO.read(DOSSIER_PDF_EXPORT_LOGO_SRC), width: 300, position: :center end format_in_2_columns(pdf, 'Dossier Nº', @dossier.id.to_s) - format_in_2_columns(pdf, 'Démarche', @procedure.libelle) - format_in_2_columns(pdf, 'Organisme', @procedure.organisation_name) + format_in_2_columns(pdf, 'Démarche', @dossier.procedure.libelle) + format_in_2_columns(pdf, 'Organisme', @dossier.procedure.organisation_name) add_etat_dossier(pdf, @dossier) diff --git a/config/env.example.optional b/config/env.example.optional index 8cee6a933..51b05c16d 100644 --- a/config/env.example.optional +++ b/config/env.example.optional @@ -69,7 +69,7 @@ DS_ENV="staging" # PROCEDURE_DEFAULT_LOGO_SRC="republique-francaise-logo.svg" # Instance customization: PDF export logo ---> to be put in "app/assets/images" -# DOSSIER_PDF_EXPORT_LOGO_SRC="app/assets/images/header/logo-ds-wide.png" +# DOSSIER_PDF_EXPORT_LOGO_SRC="app/assets/images/header/logo-ds-wide.svg" # Instance customization: watermark for identity documents # WATERMARK_FILE="" diff --git a/config/initializers/images.rb b/config/initializers/images.rb index 161c9fc24..c488aa279 100644 --- a/config/initializers/images.rb +++ b/config/initializers/images.rb @@ -17,4 +17,4 @@ MAILER_FOOTER_LOGO_SRC = ENV.fetch("MAILER_FOOTER_LOGO_SRC", "mailer/instructeur PROCEDURE_DEFAULT_LOGO_SRC = ENV.fetch("PROCEDURE_DEFAULT_LOGO_SRC", "republique-francaise-logo.svg") # Logo in PDF export of a "Dossier" -DOSSIER_PDF_EXPORT_LOGO_SRC = ENV.fetch("DOSSIER_PDF_EXPORT_LOGO_SRC", "app/assets/images/header/logo-ds-wide.png") +DOSSIER_PDF_EXPORT_LOGO_SRC = ENV.fetch("DOSSIER_PDF_EXPORT_LOGO_SRC", "app/assets/images/header/logo-ds-wide.svg") diff --git a/spec/services/pieces_justificatives_service_spec.rb b/spec/services/pieces_justificatives_service_spec.rb index a262d6817..a7b715786 100644 --- a/spec/services/pieces_justificatives_service_spec.rb +++ b/spec/services/pieces_justificatives_service_spec.rb @@ -192,7 +192,7 @@ describe PiecesJustificativesService do describe '.generate_dossier_export' do let(:dossier) { create(:dossier) } - subject { PiecesJustificativesService.generate_dossier_export(Dossier.where(id: dossier.id)) } + subject { PiecesJustificativesService.generate_dossier_export(dossier) } it "doesn't update dossier" do expect { subject }.not_to change { dossier.updated_at }