From ace8441ec7b77b3a01c10d8fec1a4c87bc601449 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Tue, 10 Apr 2018 12:24:49 +0200 Subject: [PATCH 1/5] SIRETService -> ApiEntrepriseService --- app/controllers/champs/siret_controller.rb | 2 +- app/controllers/users/dossiers_controller.rb | 2 +- app/jobs/etablissement_update_job.rb | 2 +- app/services/{siret_service.rb => api_entreprise_service.rb} | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename app/services/{siret_service.rb => api_entreprise_service.rb} (97%) diff --git a/app/controllers/champs/siret_controller.rb b/app/controllers/champs/siret_controller.rb index b1fb41b55..d735d2de4 100644 --- a/app/controllers/champs/siret_controller.rb +++ b/app/controllers/champs/siret_controller.rb @@ -14,7 +14,7 @@ class Champs::SiretController < ApplicationController end @error = "SIRET invalide" else - etablissement_attributes = SIRETService.fetch(siret, @champ.dossier.procedure_id) + etablissement_attributes = ApiEntrepriseService.fetch(siret, @champ.dossier.procedure_id) if etablissement_attributes.present? @etablissement = @champ.build_etablissement(etablissement_attributes) @etablissement.champ = @champ diff --git a/app/controllers/users/dossiers_controller.rb b/app/controllers/users/dossiers_controller.rb index 12fd0573a..c9484b5c7 100644 --- a/app/controllers/users/dossiers_controller.rb +++ b/app/controllers/users/dossiers_controller.rb @@ -107,7 +107,7 @@ class Users::DossiersController < UsersController update_current_user_siret!(siret) - etablissement_attributes = SIRETService.fetch(siret, @facade.dossier.procedure_id, @facade.dossier) + etablissement_attributes = ApiEntrepriseService.fetch(siret, @facade.dossier.procedure_id, @facade.dossier) if etablissement_attributes.present? etablissement_attributes = ActionController::Parameters.new(etablissement_attributes).permit! diff --git a/app/jobs/etablissement_update_job.rb b/app/jobs/etablissement_update_job.rb index 10566f8cf..4ccf5c440 100644 --- a/app/jobs/etablissement_update_job.rb +++ b/app/jobs/etablissement_update_job.rb @@ -2,7 +2,7 @@ class EtablissementUpdateJob < ApplicationJob queue_as :default def perform(dossier, siret) - etablissement_attributes = SIRETService.fetch(siret, dossier.procedure_id, dossier) + etablissement_attributes = ApiEntrepriseService.fetch(siret, dossier.procedure_id, dossier) if etablissement_attributes.present? if dossier.entreprise.present? diff --git a/app/services/siret_service.rb b/app/services/api_entreprise_service.rb similarity index 97% rename from app/services/siret_service.rb rename to app/services/api_entreprise_service.rb index a037fe2b5..cbdd47446 100644 --- a/app/services/siret_service.rb +++ b/app/services/api_entreprise_service.rb @@ -1,4 +1,4 @@ -class SIRETService +class ApiEntrepriseService def self.fetch(siret, procedure_id, dossier = nil) etablissement_params = ApiEntreprise::EtablissementAdapter.new(siret, procedure_id).to_params entreprise_params = ApiEntreprise::EntrepriseAdapter.new(siret, procedure_id).to_params From be672e19bcb8851faba93cab586831cff82d2457 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Tue, 10 Apr 2018 12:26:06 +0200 Subject: [PATCH 2/5] ApiEntrepriseService #fetch -> #get_etablissement_params_for_siret --- app/controllers/champs/siret_controller.rb | 2 +- app/controllers/users/dossiers_controller.rb | 2 +- app/jobs/etablissement_update_job.rb | 2 +- app/services/api_entreprise_service.rb | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/champs/siret_controller.rb b/app/controllers/champs/siret_controller.rb index d735d2de4..cbe0a70ad 100644 --- a/app/controllers/champs/siret_controller.rb +++ b/app/controllers/champs/siret_controller.rb @@ -14,7 +14,7 @@ class Champs::SiretController < ApplicationController end @error = "SIRET invalide" else - etablissement_attributes = ApiEntrepriseService.fetch(siret, @champ.dossier.procedure_id) + etablissement_attributes = ApiEntrepriseService.get_etablissement_params_for_siret(siret, @champ.dossier.procedure_id) if etablissement_attributes.present? @etablissement = @champ.build_etablissement(etablissement_attributes) @etablissement.champ = @champ diff --git a/app/controllers/users/dossiers_controller.rb b/app/controllers/users/dossiers_controller.rb index c9484b5c7..f02b3b992 100644 --- a/app/controllers/users/dossiers_controller.rb +++ b/app/controllers/users/dossiers_controller.rb @@ -107,7 +107,7 @@ class Users::DossiersController < UsersController update_current_user_siret!(siret) - etablissement_attributes = ApiEntrepriseService.fetch(siret, @facade.dossier.procedure_id, @facade.dossier) + etablissement_attributes = ApiEntrepriseService.get_etablissement_params_for_siret(siret, @facade.dossier.procedure_id, @facade.dossier) if etablissement_attributes.present? etablissement_attributes = ActionController::Parameters.new(etablissement_attributes).permit! diff --git a/app/jobs/etablissement_update_job.rb b/app/jobs/etablissement_update_job.rb index 4ccf5c440..fa85e144c 100644 --- a/app/jobs/etablissement_update_job.rb +++ b/app/jobs/etablissement_update_job.rb @@ -2,7 +2,7 @@ class EtablissementUpdateJob < ApplicationJob queue_as :default def perform(dossier, siret) - etablissement_attributes = ApiEntrepriseService.fetch(siret, dossier.procedure_id, dossier) + etablissement_attributes = ApiEntrepriseService.get_etablissement_params_for_siret(siret, dossier.procedure_id, dossier) if etablissement_attributes.present? if dossier.entreprise.present? diff --git a/app/services/api_entreprise_service.rb b/app/services/api_entreprise_service.rb index cbdd47446..ea77019a9 100644 --- a/app/services/api_entreprise_service.rb +++ b/app/services/api_entreprise_service.rb @@ -1,5 +1,5 @@ class ApiEntrepriseService - def self.fetch(siret, procedure_id, dossier = nil) + def self.get_etablissement_params_for_siret(siret, procedure_id, dossier = nil) etablissement_params = ApiEntreprise::EtablissementAdapter.new(siret, procedure_id).to_params entreprise_params = ApiEntreprise::EntrepriseAdapter.new(siret, procedure_id).to_params From 03c045aa1a9753b4c1cb4eae58a6fb6ad7fded9f Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Tue, 10 Apr 2018 12:35:47 +0200 Subject: [PATCH 3/5] =?UTF-8?q?Don=E2=80=99t=20reinvent=20the=20wheel=20wi?= =?UTF-8?q?th=20number=5Fto=5Fcurrency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/etablissement_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/etablissement_helper.rb b/app/helpers/etablissement_helper.rb index 99bfa433e..3c4de3d6f 100644 --- a/app/helpers/etablissement_helper.rb +++ b/app/helpers/etablissement_helper.rb @@ -1,5 +1,5 @@ module EtablissementHelper def pretty_currency(capital_social) - number_to_currency(capital_social, delimiter: ' ', unit: '€', format: '%n %u') + number_to_currency(capital_social, locale: :fr) end end From 7cf21d51715bc135f4fdb0f016fdcc50ad049a35 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Mon, 9 Apr 2018 15:13:37 +0200 Subject: [PATCH 4/5] User header should not display the 'go to user interface' button --- app/views/layouts/_new_header.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/_new_header.haml b/app/views/layouts/_new_header.haml index 01a230c03..4e68d1123 100644 --- a/app/views/layouts/_new_header.haml +++ b/app/views/layouts/_new_header.haml @@ -58,7 +58,7 @@ = image_tag "icons/super-admin.svg" Passer en super-admin - if SwitchDeviseProfileService.new(warden).multiple_devise_profile_connect? - - if user_signed_in? && nav_bar_profile != :usager + - if user_signed_in? && nav_bar_profile != :user %li = link_to users_dossiers_path, class: "menu-item menu-link" do = image_tag "icons/switch-profile.svg" From 4cc517ccba282246ad2be09780441b5f9e98224d Mon Sep 17 00:00:00 2001 From: Frederic Merizen Date: Wed, 11 Apr 2018 09:33:06 +0200 Subject: [PATCH 5/5] Do not use deliver_late MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit as the delayed job wouldn’t play nicely with the Mailer in lib/ in production --- lib/tasks/2018_04_03_attestation_closed_mail_discrepancy.rake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/tasks/2018_04_03_attestation_closed_mail_discrepancy.rake b/lib/tasks/2018_04_03_attestation_closed_mail_discrepancy.rake index 7da13b039..72db6d867 100644 --- a/lib/tasks/2018_04_03_attestation_closed_mail_discrepancy.rake +++ b/lib/tasks/2018_04_03_attestation_closed_mail_discrepancy.rake @@ -3,7 +3,8 @@ namespace :'2018_04_03_attestation_closed_mail_discrepancy' do Administrateur.includes(:procedures).find_each(batch_size: 10) do |admin| procedures = admin.procedures.where(archived_at: nil).select { |p| p.closed_mail_template_attestation_inconsistency_state == :missing_tag } if procedures.any? - Mailers::AttestationClosedMailDiscrepancyMailer.missing_attestation_tag_email(admin, procedures).deliver_later + # Use `deliver_now` because the delayed job cannot find the `Mailers::AttestationClosedMailDiscrepancyMaile` class in production + Mailers::AttestationClosedMailDiscrepancyMailer.missing_attestation_tag_email(admin, procedures).deliver_now! print "#{admin.email}\n" end end