From dceb30c50405a37d35abd7f6bc9780ee811d0bfa Mon Sep 17 00:00:00 2001 From: Frederic Merizen Date: Wed, 9 May 2018 10:32:22 +0200 Subject: [PATCH 01/15] =?UTF-8?q?Espace=20ins=C3=A9cable=20avant=20le=20si?= =?UTF-8?q?gne=20pourcent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 77e1fbc6d..22282b41a 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ## Context -demarches-simplifiees.fr est un site web conçue afin de répondre au besoin urgent de l'État d'appliquer la directive sur le 100 % dématérialisation pour les procédures administratives. +demarches-simplifiees.fr est un site web conçu afin de répondre au besoin urgent de l'État d'appliquer la directive sur le 100 % dématérialisation pour les procédures administratives. ## Dépendances From 3e176d4e08b302b3aa1e5e6c8eb9480fb5d79521 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Wed, 9 May 2018 12:03:04 +0200 Subject: [PATCH 02/15] Remove use of staging.apientreprise --- config/initializers/urls.rb | 6 +----- spec/controllers/users/dossiers_controller_spec.rb | 10 +++++----- spec/features/users/complete_demande_spec.rb | 8 ++++---- spec/features/users/dossier_creation_spec.rb | 8 ++++---- spec/features/users/start_demande_spec.rb | 8 ++++---- spec/lib/api_entreprise/api_spec.rb | 8 ++++---- spec/lib/api_entreprise/entreprise_adapter_spec.rb | 2 +- spec/lib/api_entreprise/etablissement_adapter_spec.rb | 4 ++-- spec/lib/api_entreprise/exercices_adapter_spec.rb | 2 +- spec/lib/api_entreprise/rna_adapter_spec.rb | 2 +- 10 files changed, 27 insertions(+), 31 deletions(-) diff --git a/config/initializers/urls.rb b/config/initializers/urls.rb index 510cd60ea..7d9eb1124 100644 --- a/config/initializers/urls.rb +++ b/config/initializers/urls.rb @@ -1,7 +1,3 @@ -if Rails.env.production? - API_ENTREPRISE_URL = 'https://entreprise.api.gouv.fr/v2' -else - API_ENTREPRISE_URL = 'https://staging.entreprise.api.gouv.fr/v2' -end +API_ENTREPRISE_URL = 'https://entreprise.api.gouv.fr/v2' PIPEDRIVE_API_URL = 'https://api.pipedrive.com/v1' diff --git a/spec/controllers/users/dossiers_controller_spec.rb b/spec/controllers/users/dossiers_controller_spec.rb index 53a550401..8eff31ad1 100644 --- a/spec/controllers/users/dossiers_controller_spec.rb +++ b/spec/controllers/users/dossiers_controller_spec.rb @@ -178,19 +178,19 @@ describe Users::DossiersController, type: :controller do let(:user) { create(:user) } before do - stub_request(:get, /https:\/\/staging.entreprise.api.gouv.fr\/v2\/etablissements\/#{siret_not_found}?.*token=/) + stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/etablissements\/#{siret_not_found}?.*token=/) .to_return(status: 404, body: 'fake body') - stub_request(:get, /https:\/\/staging.entreprise.api.gouv.fr\/v2\/etablissements\/#{siret}?.*token=/) + stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/etablissements\/#{siret}?.*token=/) .to_return(status: status_entreprise_call, body: File.read('spec/support/files/etablissement.json')) - stub_request(:get, /https:\/\/staging.entreprise.api.gouv.fr\/v2\/entreprises\/#{siren}?.*token=/) + stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/entreprises\/#{siren}?.*token=/) .to_return(status: status_entreprise_call, body: File.read('spec/support/files/entreprise.json')) - stub_request(:get, /https:\/\/staging.entreprise.api.gouv.fr\/v2\/exercices\/#{siret}?.*token=/) + stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/exercices\/#{siret}?.*token=/) .to_return(status: exercices_status, body: exercices_body) - stub_request(:get, /https:\/\/staging.entreprise.api.gouv.fr\/v2\/associations\/#{siret}?.*token=/) + stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/associations\/#{siret}?.*token=/) .to_return(status: rna_status, body: rna_body) dossier diff --git a/spec/features/users/complete_demande_spec.rb b/spec/features/users/complete_demande_spec.rb index 5d8391174..25d639ae8 100644 --- a/spec/features/users/complete_demande_spec.rb +++ b/spec/features/users/complete_demande_spec.rb @@ -30,14 +30,14 @@ feature 'user path for dossier creation' do end context 'sets siret' do before do - stub_request(:get, /https:\/\/staging.entreprise.api.gouv.fr\/v2\/etablissements\/#{siret}?.*token=/) + stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/etablissements\/#{siret}?.*token=/) .to_return(body: File.read('spec/support/files/etablissement.json', status: 200)) - stub_request(:get, /https:\/\/staging.entreprise.api.gouv.fr\/v2\/entreprises\/#{siren}?.*token=/) + stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/entreprises\/#{siren}?.*token=/) .to_return(status: 200, body: File.read('spec/support/files/entreprise.json')) - stub_request(:get, /https:\/\/staging.entreprise.api.gouv.fr\/v2\/exercices\/#{siret}?.*token=/) + stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/exercices\/#{siret}?.*token=/) .to_return(status: 200, body: File.read('spec/support/files/exercices.json')) - stub_request(:get, /https:\/\/staging.entreprise.api.gouv.fr\/v2\/associations\/#{siret}?.*token=/) + stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/associations\/#{siret}?.*token=/) .to_return(status: 404, body: '') page.find_by_id('dossier-siret').set siret diff --git a/spec/features/users/dossier_creation_spec.rb b/spec/features/users/dossier_creation_spec.rb index 84572b3d5..6b15bf0a1 100644 --- a/spec/features/users/dossier_creation_spec.rb +++ b/spec/features/users/dossier_creation_spec.rb @@ -67,13 +67,13 @@ feature 'As a User I wanna create a dossier' do visit commencer_path(procedure_path: procedure_with_siret.path) expect(page).to have_current_path(users_dossier_path(procedure_with_siret.dossiers.last.id.to_s)) fill_in 'dossier-siret', with: siret - stub_request(:get, /https:\/\/staging.entreprise.api.gouv.fr\/v2\/etablissements\/#{siret}?.*token=/) + stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/etablissements\/#{siret}?.*token=/) .to_return(status: 200, body: File.read('spec/support/files/etablissement.json')) - stub_request(:get, /https:\/\/staging.entreprise.api.gouv.fr\/v2\/entreprises\/#{siren}?.*token=/) + stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/entreprises\/#{siren}?.*token=/) .to_return(status: 200, body: File.read('spec/support/files/entreprise.json')) - stub_request(:get, /https:\/\/staging.entreprise.api.gouv.fr\/v2\/exercices\/#{siret}?.*token=/) + stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/exercices\/#{siret}?.*token=/) .to_return(status: 200, body: File.read('spec/support/files/exercices.json')) - stub_request(:get, /https:\/\/staging.entreprise.api.gouv.fr\/v2\/associations\/#{siret}?.*token=/) + stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/associations\/#{siret}?.*token=/) .to_return(status: 404, body: '') page.find_by_id('dossier-siret').set siret page.find_by_id('submit-siret').click diff --git a/spec/features/users/start_demande_spec.rb b/spec/features/users/start_demande_spec.rb index e1f141928..40aac6547 100644 --- a/spec/features/users/start_demande_spec.rb +++ b/spec/features/users/start_demande_spec.rb @@ -26,13 +26,13 @@ feature 'user arrive on siret page' do end context 'when enter a siret', js: true do before do - stub_request(:get, /https:\/\/staging.entreprise.api.gouv.fr\/v2\/etablissements\/#{siret}?.*token=/) + stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/etablissements\/#{siret}?.*token=/) .to_return(status: 200, body: File.read('spec/support/files/etablissement.json')) - stub_request(:get, /https:\/\/staging.entreprise.api.gouv.fr\/v2\/entreprises\/#{siren}?.*token=/) + stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/entreprises\/#{siren}?.*token=/) .to_return(status: 200, body: File.read('spec/support/files/entreprise.json')) - stub_request(:get, /https:\/\/staging.entreprise.api.gouv.fr\/v2\/exercices\/#{siret}?.*token=/) + stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/exercices\/#{siret}?.*token=/) .to_return(status: 200, body: File.read('spec/support/files/exercices.json')) - stub_request(:get, /https:\/\/staging.entreprise.api.gouv.fr\/v2\/associations\/#{siret}?.*token=/) + stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/associations\/#{siret}?.*token=/) .to_return(status: 404, body: '') page.find_by_id('dossier-siret').set siret diff --git a/spec/lib/api_entreprise/api_spec.rb b/spec/lib/api_entreprise/api_spec.rb index ded04e7d5..070568dba 100644 --- a/spec/lib/api_entreprise/api_spec.rb +++ b/spec/lib/api_entreprise/api_spec.rb @@ -5,7 +5,7 @@ describe ApiEntreprise::API do describe '.entreprise' do subject { described_class.entreprise(siren, procedure_id) } before do - stub_request(:get, /https:\/\/staging.entreprise.api.gouv.fr\/v2\/entreprises\/#{siren}?.*token=/) + stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/entreprises\/#{siren}?.*token=/) .to_return(status: status, body: body) end context 'when siren does not exist' do @@ -31,7 +31,7 @@ describe ApiEntreprise::API do describe '.etablissement' do subject { described_class.etablissement(siret, procedure_id) } before do - stub_request(:get, /https:\/\/staging.entreprise.api.gouv.fr\/v2\/etablissements\/#{siret}?.*token=/) + stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/etablissements\/#{siret}?.*token=/) .to_return(status: status, body: body) end @@ -58,7 +58,7 @@ describe ApiEntreprise::API do describe '.exercices' do before do - stub_request(:get, /https:\/\/staging.entreprise.api.gouv.fr\/v2\/exercices\/.*token=/) + stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/exercices\/.*token=/) .to_return(status: status, body: body) end @@ -89,7 +89,7 @@ describe ApiEntreprise::API do describe '.rna' do before do - stub_request(:get, /https:\/\/staging.entreprise.api.gouv.fr\/v2\/associations\/.*token=/) + stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/associations\/.*token=/) .to_return(status: status, body: body) end diff --git a/spec/lib/api_entreprise/entreprise_adapter_spec.rb b/spec/lib/api_entreprise/entreprise_adapter_spec.rb index af559f3ac..f9eaf62eb 100644 --- a/spec/lib/api_entreprise/entreprise_adapter_spec.rb +++ b/spec/lib/api_entreprise/entreprise_adapter_spec.rb @@ -7,7 +7,7 @@ describe ApiEntreprise::EntrepriseAdapter do subject { adapter.to_params } before do - stub_request(:get, /https:\/\/staging.entreprise.api.gouv.fr\/v2\/entreprises\/#{siren}?.*token=/) + stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/entreprises\/#{siren}?.*token=/) .to_return(body: File.read('spec/support/files/entreprise.json', status: 200)) end diff --git a/spec/lib/api_entreprise/etablissement_adapter_spec.rb b/spec/lib/api_entreprise/etablissement_adapter_spec.rb index e9a3a5c02..31f21414a 100644 --- a/spec/lib/api_entreprise/etablissement_adapter_spec.rb +++ b/spec/lib/api_entreprise/etablissement_adapter_spec.rb @@ -8,7 +8,7 @@ describe ApiEntreprise::EtablissementAdapter do subject { described_class.new(siret, procedure_id).to_params } before do - stub_request(:get, /https:\/\/staging.entreprise.api.gouv.fr\/v2\/etablissements\/#{siret}?.*token=/) + stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/etablissements\/#{siret}?.*token=/) .to_return(body: File.read('spec/support/files/etablissement.json', status: 200)) end @@ -75,7 +75,7 @@ describe ApiEntreprise::EtablissementAdapter do subject { described_class.new(bad_siret, 12).to_params } before do - stub_request(:get, /https:\/\/staging.entreprise.api.gouv.fr\/v2\/etablissements\/#{bad_siret}?.*token=/) + stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/etablissements\/#{bad_siret}?.*token=/) .to_return(body: 'Fake body', status: 404) end diff --git a/spec/lib/api_entreprise/exercices_adapter_spec.rb b/spec/lib/api_entreprise/exercices_adapter_spec.rb index 4feec27da..bdfe2c7da 100644 --- a/spec/lib/api_entreprise/exercices_adapter_spec.rb +++ b/spec/lib/api_entreprise/exercices_adapter_spec.rb @@ -6,7 +6,7 @@ describe ApiEntreprise::ExercicesAdapter do subject { described_class.new(siret, procedure_id).to_params } before do - stub_request(:get, /https:\/\/staging.entreprise.api.gouv.fr\/v2\/exercices\/.*token=/) + stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/exercices\/.*token=/) .to_return(body: File.read('spec/support/files/exercices.json', status: 200)) end diff --git a/spec/lib/api_entreprise/rna_adapter_spec.rb b/spec/lib/api_entreprise/rna_adapter_spec.rb index 7edbcb2aa..2df856cbe 100644 --- a/spec/lib/api_entreprise/rna_adapter_spec.rb +++ b/spec/lib/api_entreprise/rna_adapter_spec.rb @@ -10,7 +10,7 @@ describe ApiEntreprise::RNAAdapter do subject { adapter.to_params } before do - stub_request(:get, /https:\/\/staging.entreprise.api.gouv.fr\/v2\/associations\/.*token=/) + stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/associations\/.*token=/) .to_return(body: body, status: status) end From 5fd5c3ee5b94454970803db9e7da2d58b96a6c7c Mon Sep 17 00:00:00 2001 From: Frederic Merizen Date: Wed, 9 May 2018 16:15:19 +0200 Subject: [PATCH 03/15] =?UTF-8?q?[#1833]=20Add=20=E2=80=98create=20from=20?= =?UTF-8?q?scratch=E2=80=99=20button=20to=20procedure=20library?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/admin/procedures/new_from_existing.html.haml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/views/admin/procedures/new_from_existing.html.haml b/app/views/admin/procedures/new_from_existing.html.haml index a226fd66a..9fbb9755e 100644 --- a/app/views/admin/procedures/new_from_existing.html.haml +++ b/app/views/admin/procedures/new_from_existing.html.haml @@ -1,3 +1,7 @@ +.row.white-back + %a#from-scratch{ href: new_admin_procedure_path, class: 'btn-sm btn-primary' } + Créer une nouvelle procédure de zéro + .row.white-back %h2 Créer une nouvelle procédure à partir d'une procédure existante From 93e068421bee8af4caa4cfbedcad8d7a5caf10c8 Mon Sep 17 00:00:00 2001 From: Frederic Merizen Date: Wed, 9 May 2018 16:16:09 +0200 Subject: [PATCH 04/15] [#1833] New procedure button defaults to procedure library --- app/views/admin/procedures/index.html.haml | 2 +- spec/features/admin/procedure_cloning_spec.rb | 1 + spec/features/admin/procedure_creation_spec.rb | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/views/admin/procedures/index.html.haml b/app/views/admin/procedures/index.html.haml index 89ed60b86..540c498fc 100644 --- a/app/views/admin/procedures/index.html.haml +++ b/app/views/admin/procedures/index.html.haml @@ -6,7 +6,7 @@ .carret-right .carret-down Procédures - %a{ href: '/admin/procedures/new' } + %a{ href: new_from_existing_admin_procedures_path } #new-procedure.col-lg-2.col-md-2.col-sm-2.col-xs-2.action Nouvelle diff --git a/spec/features/admin/procedure_cloning_spec.rb b/spec/features/admin/procedure_cloning_spec.rb index 8d8020641..149bf0242 100644 --- a/spec/features/admin/procedure_cloning_spec.rb +++ b/spec/features/admin/procedure_cloning_spec.rb @@ -11,6 +11,7 @@ feature 'As an administrateur I wanna clone a procedure', js: true do context 'Cloning procedure' do before 'Create procedure' do page.find_by_id('new-procedure').click + page.find_by_id('from-scratch').click fill_in 'procedure_libelle', with: 'libelle de la procedure' page.execute_script("$('#procedure_description').val('description de la procedure')") fill_in 'procedure_organisation', with: 'organisme de la procedure' diff --git a/spec/features/admin/procedure_creation_spec.rb b/spec/features/admin/procedure_creation_spec.rb index 41a3a3f84..6599b832b 100644 --- a/spec/features/admin/procedure_creation_spec.rb +++ b/spec/features/admin/procedure_creation_spec.rb @@ -28,11 +28,13 @@ feature 'As an administrateur I wanna create a new procedure', js: true do context 'Creating a new procedure' do scenario 'Finding new procedure link' do page.find_by_id('new-procedure').click + page.find_by_id('from-scratch').click expect(page).to have_current_path(new_admin_procedure_path) end scenario 'Finding save button for new procedure, libelle and description required' do page.find_by_id('new-procedure').click + page.find_by_id('from-scratch').click page.find_by_id('save-procedure').click page.find_by_id('flash_message').visible? fill_in 'procedure_libelle', with: 'libelle de la procedure' @@ -46,6 +48,7 @@ feature 'As an administrateur I wanna create a new procedure', js: true do context 'Editing a new procedure' do before 'Create procedure' do page.find_by_id('new-procedure').click + page.find_by_id('from-scratch').click fill_in 'procedure_libelle', with: 'libelle de la procedure' page.execute_script("$('#procedure_description').val('description de la procedure')") fill_in 'procedure_organisation', with: 'organisme de la procedure' From 430853545095f268c8198312a2bf80e9f9dc9b27 Mon Sep 17 00:00:00 2001 From: Frederic Merizen Date: Wed, 9 May 2018 16:16:43 +0200 Subject: [PATCH 05/15] [Fix #1833] Remove library button from new procedure from scratch screen --- app/views/admin/procedures/new.html.haml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/views/admin/procedures/new.html.haml b/app/views/admin/procedures/new.html.haml index 98c92f966..1b203b146 100644 --- a/app/views/admin/procedures/new.html.haml +++ b/app/views/admin/procedures/new.html.haml @@ -1,7 +1,3 @@ -.row.white-back - %a{ href: new_from_existing_admin_procedures_path, class: 'btn-sm btn-primary' } - Créer une nouvelle procédure à partir d'une procédure existante - .row.white-back %h2 = t('dynamics.admin.dossiers.tableau_de_bord.nouvelle_procedure') From 46ba728d8a08d2a065aee2e9b5d9c128757c15f4 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Wed, 9 May 2018 15:36:47 +0200 Subject: [PATCH 06/15] [fix #1913] force ssl and secure cookies --- config/environments/production.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index c27fd85c1..32972ab87 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -42,7 +42,7 @@ Rails.application.configure do # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. - # config.force_ssl = true + config.force_ssl = true # Use the lowest log level to ensure availability of diagnostic information # when problems arise. From 26f9ec0122374556084cd1f131d744adc258d774 Mon Sep 17 00:00:00 2001 From: Frederic Merizen Date: Wed, 9 May 2018 18:28:41 +0200 Subject: [PATCH 07/15] [Fix #1825] Also show previews for archived procedures --- app/views/admin/procedures/new_from_existing.html.haml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/views/admin/procedures/new_from_existing.html.haml b/app/views/admin/procedures/new_from_existing.html.haml index 9fbb9755e..3935e0722 100644 --- a/app/views/admin/procedures/new_from_existing.html.haml +++ b/app/views/admin/procedures/new_from_existing.html.haml @@ -19,8 +19,7 @@ %td{ style: 'width: 750px;' } = procedure.libelle %td{ style: 'padding-right: 10px; padding-left: 10px; width: 60px;' } - - if !procedure.archivee? - = link_to('Consulter', apercu_procedure_path(id: procedure.id), target: "_blank") + = link_to('Consulter', apercu_procedure_path(id: procedure.id), target: "_blank") %td = link_to('Cloner', admin_procedure_clone_path(procedure.id, from_new_from_existing: true), 'data-method' => :put, class: 'btn-sm btn-primary clone-btn') %td{ style: 'padding-left: 10px;' } From f8273ca8aeddde42c1c270e6766e1de0aa7f2239 Mon Sep 17 00:00:00 2001 From: Frederic Merizen Date: Wed, 9 May 2018 18:44:09 +0200 Subject: [PATCH 08/15] Make match order-insensitive to avoid spurious test failures --- spec/jobs/find_dubious_procedures_job_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/jobs/find_dubious_procedures_job_spec.rb b/spec/jobs/find_dubious_procedures_job_spec.rb index e8b354f99..8303b9d39 100644 --- a/spec/jobs/find_dubious_procedures_job_spec.rb +++ b/spec/jobs/find_dubious_procedures_job_spec.rb @@ -29,7 +29,7 @@ RSpec.describe FindDubiousProceduresJob, type: :job do receive_procedure, receive_forbidden_tdcs = @dubious_procedures_args[0] expect(receive_procedure).to eq(procedure) - expect(receive_forbidden_tdcs).to match(forbidden_tdcs) + expect(receive_forbidden_tdcs).to match_array(forbidden_tdcs) expect(AdministrationMailer).to have_received(:dubious_procedures).with(@dubious_procedures_args) end From 748300fcf75a2aa4d779506b83baec06d23a4ccd Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Fri, 11 May 2018 13:52:06 +0200 Subject: [PATCH 09/15] [Fix #1896] fix typo --- .../dossiers/editable_champs/_piece_justificative.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/shared/dossiers/editable_champs/_piece_justificative.html.haml b/app/views/shared/dossiers/editable_champs/_piece_justificative.html.haml index b3855124a..c541ffdda 100644 --- a/app/views/shared/dossiers/editable_champs/_piece_justificative.html.haml +++ b/app/views/shared/dossiers/editable_champs/_piece_justificative.html.haml @@ -2,7 +2,7 @@ - if champ.type_de_champ.piece_justificative_template.attached? %p.edit-pj-template.mb-1 - Veuillez télécharger, remplir et joindre le + Veuillez télécharger, remplir et joindre = link_to('le modèle suivant', url_for(champ.type_de_champ.piece_justificative_template), target: '_blank') - if !pj.attached? From 0c54220c2bf960f0c0cbdb3b369e5998c99065a9 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Wed, 9 May 2018 17:02:04 +0100 Subject: [PATCH 10/15] Add test_started_at to procedures --- app/models/procedure.rb | 3 ++- .../20180423141411_add_test_started_at_to_procedures.rb | 5 +++++ db/schema.rb | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20180423141411_add_test_started_at_to_procedures.rb diff --git a/app/models/procedure.rb b/app/models/procedure.rb index b9ee0dfa4..30a47fc5a 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -153,7 +153,8 @@ class Procedure < ApplicationRecord end def publish!(path) - self.update!({ published_at: Time.now, archived_at: nil }) + now = Time.now + self.update!({ test_started_at: now, published_at: now, archived_at: nil }) ProcedurePath.create!(path: path, procedure: self, administrateur: self.administrateur) end diff --git a/db/migrate/20180423141411_add_test_started_at_to_procedures.rb b/db/migrate/20180423141411_add_test_started_at_to_procedures.rb new file mode 100644 index 000000000..d42154c5e --- /dev/null +++ b/db/migrate/20180423141411_add_test_started_at_to_procedures.rb @@ -0,0 +1,5 @@ +class AddTestStartedAtToProcedures < ActiveRecord::Migration[5.2] + def change + add_column :procedures, :test_started_at, :datetime, index: true + end +end diff --git a/db/schema.rb b/db/schema.rb index c1b888d2c..3434709d1 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -464,6 +464,7 @@ ActiveRecord::Schema.define(version: 2018_05_02_092852) do t.string "web_hook_url" t.boolean "cloned_from_library", default: false t.bigint "parent_procedure_id" + t.datetime "test_started_at" t.index ["hidden_at"], name: "index_procedures_on_hidden_at" t.index ["parent_procedure_id"], name: "index_procedures_on_parent_procedure_id" end From 32787d74319ae0e0e7effb2690eadcae2ea66428 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Wed, 9 May 2018 17:11:20 +0100 Subject: [PATCH 11/15] Task to add test_started_at to all procedures --- .../2018_05_09_add_test_started_at_to_procedure.rake | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 lib/tasks/2018_05_09_add_test_started_at_to_procedure.rake diff --git a/lib/tasks/2018_05_09_add_test_started_at_to_procedure.rake b/lib/tasks/2018_05_09_add_test_started_at_to_procedure.rake new file mode 100644 index 000000000..198d1644d --- /dev/null +++ b/lib/tasks/2018_05_09_add_test_started_at_to_procedure.rake @@ -0,0 +1,8 @@ +namespace :'2018_05_09_add_test_started_at_to_procedure' do + task set: :environment do + Procedure.publiees_ou_archivees.where(test_started_at: nil).find_each do |procedure| + procedure.test_started_at = procedure.published_at + procedure.save + end + end +end From 95db5e5767d8b0f4164db2e66385ab572d4c5fe9 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Tue, 15 May 2018 12:26:55 +0200 Subject: [PATCH 12/15] [fix #1560] update logo in mail --- .../mailer/gestionnaire_mailer/logo.png | Bin 2501 -> 6773 bytes app/views/layouts/mailers/layout.html.erb | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) mode change 100755 => 100644 app/assets/images/mailer/gestionnaire_mailer/logo.png diff --git a/app/assets/images/mailer/gestionnaire_mailer/logo.png b/app/assets/images/mailer/gestionnaire_mailer/logo.png old mode 100755 new mode 100644 index 1b1255204fefa2e359408797ad9f85ee891bfb1c..34a48e8bcc43b0780d5b5ba5d72f2e3101589d5e GIT binary patch literal 6773 zcmV-*8j9tKP){r?ej(F}3W$KUk`ZqM&zbN~PVW2E8r`u<^};grDZ?e+WxZO`Z^Jk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S)29jUV5I@@|u)Jko)Zt;yS1Ru_ zcE9K8Wui#xtGIAa5PW&kIe~RqZwnKTi5$%JtVcI!>h5jA1GZx6B2j9OFbHM)UcZ@U*fZFq6mkP5nLAnyVKyYjW~;*^yg;<<%KV z2O8=4%-`~hDUhX%;@RbtYk9i{W13`k=52ZN_)vR-8s_Iie8U<)9E1FhO8m3e z%~+vJQPkx?!caPyRVH3D&kZD>&XP2gB1OVW+;i|(7QFV#hq*OL@uLsXXP6)K#tYbr ztP;OuN?HcncQ;YE!H&$=g<bntP7+m6;cm4vQ_u^ZtAP8WtjatrpuaU&!(U@+r~j?Aao zpH|=xlJ?D}28aDyFgsg#-|&nLa!Y(l0r9z(s_z*y>C|wQaPE_fMo$t|2*Iuk_=YY` z>huUrMn9S_hk@+7Rljr9?VIF=u|IQ3ghuXTy4R0|pHsN9r>PNSQIY$asABKFD<9&! z88o1iLq~*v1At{uL^Qt5C#rn7t#$P+KJw0qX0iT&kay5kW*l1CO zug1Ua+hk`stGHW*{a$RfWjhlChd{dPWEKQSG-8AY)K$E_*MHq<-WFY$^+~;KV9bE9 zKVi4ZR1kV0^M00jVF?b049BrcxgVXI96f~>)opC9YIq3&7kjHz!c6Q_XWv#YZPL$F zV5{;f$>zr@N&`~2(I9_)f5~RSg*|v&=_w(fZUj+V4G_K&ljxd3AEo#8KT@#7N6pXI za!VKIEt>LjH&D=z(_|~%w53Q7Ce71G(T}UT>UyGkhA@gy~7zT2p3SayWffRbw;EX*j P00000NkvXXu0mjf=C$Y_ diff --git a/app/views/layouts/mailers/layout.html.erb b/app/views/layouts/mailers/layout.html.erb index 6173e75fe..7f387ece8 100644 --- a/app/views/layouts/mailers/layout.html.erb +++ b/app/views/layouts/mailers/layout.html.erb @@ -50,7 +50,7 @@
- Logo demarches-simplifiees.fr + Logo demarches-simplifiees.fr
From da8ad1f3e2f4fcd9b5016e077834395661cb57b5 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Thu, 17 May 2018 13:24:58 +0200 Subject: [PATCH 13/15] Remove external scripts from mailjet widget --- app/assets/javascripts/mailjet.js | 132 ++++++++++++++++++ .../layouts/_mailjet_newsletter.html.haml | 2 +- config/application.rb | 2 +- 3 files changed, 134 insertions(+), 2 deletions(-) create mode 100644 app/assets/javascripts/mailjet.js diff --git a/app/assets/javascripts/mailjet.js b/app/assets/javascripts/mailjet.js new file mode 100644 index 000000000..42ba7b513 --- /dev/null +++ b/app/assets/javascripts/mailjet.js @@ -0,0 +1,132 @@ +if (typeof wScriptAlreadyLoaded === "undefined") { + var wScriptAlreadyLoaded = true; + + // Array of popin translations + var i8nMessages = []; + i8nMessages['en_US'] = []; + i8nMessages['fr_FR'] = []; + i8nMessages['de_DE'] = []; + i8nMessages['es_ES'] = []; + i8nMessages['en_US']['iframe-error'] = 'Your browser does not support the IFrame element'; + i8nMessages['en_US']['close-popin'] = 'Close'; + i8nMessages['fr_FR']['iframe-error'] = 'Votre navigateur ne supporte pas l\'élément iframe'; + i8nMessages['fr_FR']['close-popin'] = 'Fermer'; + i8nMessages['de_DE']['iframe-error'] = 'Ihr navigator verträgt kein Element iframe'; + i8nMessages['de_DE']['close-popin'] = 'Schließen'; + i8nMessages['es_ES']['iframe-error'] = 'Su navegante no soporta el elemento iframe'; + i8nMessages['es_ES']['close-popin'] = 'Cerrarse'; + + window.onload = function() { + // Display popin when click event occure on widget button + Array.prototype.forEach.call(document.getElementsByClassName("mj-w-btn"), function(btnNode) { + btnNode.style.cursor = "pointer"; + btnNode.addEventListener("click", function(event) { + mjOpenPopin(event, this); + }); + }); + + mjOpenPopin = function(event, element) { + event.preventDefault(); + //event.stopPropagation(); + + //var token = str.substring(btnNode.id.lastIndexOf("-") + 1, btnNode.id.length - btnNode.id.lastIndexOf("-")); + var token = element.getAttribute("data-token"); + + //Register parameters + var widgetPopinData = document.querySelector(".mj-w-data[data-token='" + token + "']"); + if (widgetPopinData) { + var apiKey = widgetPopinData.getAttribute("data-apikey"); + var wId = widgetPopinData.getAttribute("data-w-id"); + var locale = widgetPopinData.getAttribute("data-lang"); + var base = widgetPopinData.getAttribute("data-base"); + var width = widgetPopinData.getAttribute("data-width"); + var height = widgetPopinData.getAttribute("data-height"); + var statics = widgetPopinData.getAttribute("data-statics"); + + // Call to Mailjet CSS file + var cssFile = document.createElement("link"); + cssFile.setAttribute("rel", "stylesheet"); + cssFile.setAttribute("type", "text/css"); + if (statics) { + base += "/" + statics; + } + cssFile.setAttribute("href", base + "/css/w-popin-less.css"); + document.getElementsByTagName("head")[0].appendChild(cssFile); + + var htmlCode = "
" + + "
" + + "
" + + "\""" + + "" + + "
" + + "
"; + + widgetPopinData.innerHTML = htmlCode; + + document.getElementById("mj-w-iframe").onload = function() { + + document.getElementById("mj-w-iframe").style.height= height + "px"; + document.getElementById('mj-w-close-img').style.display = "block"; + document.getElementById("mj-w-loader").style.display = "none"; + document.getElementById("mj-w-popin-block").style.border = "none"; + if (window.matchMedia("(max-width: 767px)").matches) { + document.getElementById("mj-w-iframe").style.width = '100%'; + document.getElementById("mj-w-popin-block").style.height = 'auto'; + document.getElementById("mj-w-popin-block").style.width = '90%'; + } + }; + + var closeImgNode = document.getElementById("mj-w-close-img"); + closeImgNode.addEventListener("click", function(event) { + closePopin(); + event.preventDefault(); + }); + + document.addEventListener("keydown", escapeEvent); + document.getElementById("mj-w-iframe").onclick=function(event){ + event.stopPropagation(); + }; + //document.addEventListener("click"); + + document.getElementById("mj-w-overlay").style.display = "block"; + document.getElementById("mj-w-overlay").addEventListener("click", function(event){ + closePopin(); + event.preventDefault(); + }); + } + } + + // Escape event : close popin + function escapeEvent(e) { + if (e.keyCode == 27) { // Escape key + closePopin(); + } + } + + // Close popin (remove popin HTML code) + function closePopin() { + var rootContainer = document.getElementById("mj-w-overlay"); + if(rootContainer) { + rootContainer.parentNode.removeChild(rootContainer); + } + document.removeEventListener("keypress", escapeEvent); + } + + window.onresize = function(event) { + if (window.matchMedia("(max-width: 767px)").matches) { + var popin = document.getElementById("mj-w-popin-block"); + var iframe = document.getElementById("mj-w-iframe"); + if (popin) { + popin.style.height = 'auto'; + popin.style.width = '90%'; + } + if (iframe) { + iframe.style.width = '100%'; + } + } + } + + }; +} diff --git a/app/views/layouts/_mailjet_newsletter.html.haml b/app/views/layouts/_mailjet_newsletter.html.haml index 0cf468a00..e290caf30 100644 --- a/app/views/layouts/_mailjet_newsletter.html.haml +++ b/app/views/layouts/_mailjet_newsletter.html.haml @@ -1,2 +1,2 @@ %data.mj-w-data{ "data-apikey" => "1v5T", "data-base" => "https://app.mailjet.com", "data-height" => "328", "data-lang" => "fr_FR", "data-statics" => "statics", "data-token" => "11c89e7ddb46fbcdcb7f8fe5fdfca818", "data-w-id" => "39b", "data-width" => "640", "value" => "mj" } -%script{ src: 'https://app.mailjet.com/statics/js/widget.modal.js', 'data-turbolinks-eval': 'false' } += javascript_include_tag 'mailjet', "data-turbolinks-eval": false diff --git a/config/application.rb b/config/application.rb index 7d54fd628..6e5f62433 100644 --- a/config/application.rb +++ b/config/application.rb @@ -25,7 +25,7 @@ module TPS config.autoload_paths += %W(#{config.root}/lib #{config.root}/app/validators #{config.root}/app/facades) config.assets.paths << Rails.root.join('app', 'assets', 'javascript') config.assets.paths << Rails.root.join('app', 'assets', 'fonts') - config.assets.precompile += %w(.woff) + config.assets.precompile += %w(.woff mailjet.js) if Rails.env.production? URL = "https://www.demarches-simplifiees.fr/" From a8e7038ab540760d78e0b2c571beee1f7a245df2 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Tue, 15 May 2018 17:32:12 +0200 Subject: [PATCH 14/15] Add aasm --- Gemfile | 2 ++ Gemfile.lock | 3 +++ 2 files changed, 5 insertions(+) diff --git a/Gemfile b/Gemfile index 4e03bcce1..456da8de1 100644 --- a/Gemfile +++ b/Gemfile @@ -99,6 +99,8 @@ gem 'sanitize-url' gem 'flipflop' +gem 'aasm' + # Cron jobs gem 'delayed_job_active_record' gem "daemons" diff --git a/Gemfile.lock b/Gemfile.lock index f8460ab99..532fc7acb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -29,6 +29,8 @@ GEM remote: https://rubygems.org/ specs: CFPropertyList (2.3.6) + aasm (4.12.3) + concurrent-ruby (~> 1.0) actioncable (5.2.0) actionpack (= 5.2.0) nio4r (~> 2.0) @@ -779,6 +781,7 @@ PLATFORMS ruby DEPENDENCIES + aasm active_model_serializers administrate apipie-rails From 2b8ee92074437f9a7b4979b12507ad5ac7b4d69f Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Tue, 15 May 2018 16:20:21 +0200 Subject: [PATCH 15/15] Add aasm_state to procedures --- app/models/procedure.rb | 6 +++--- db/migrate/20180515135415_add_aasm_state_to_procedures.rb | 5 +++++ db/schema.rb | 3 ++- lib/tasks/2018_05_15_add_aasm_state_to_procedure.rake | 8 ++++++++ 4 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 db/migrate/20180515135415_add_aasm_state_to_procedures.rb create mode 100644 lib/tasks/2018_05_15_add_aasm_state_to_procedure.rake diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 30a47fc5a..218081808 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -63,7 +63,7 @@ class Procedure < ApplicationRecord def hide! now = DateTime.now - self.update(hidden_at: now) + self.update(hidden_at: now, aasm_state: :hidden) self.dossiers.update_all(hidden_at: now) end @@ -154,7 +154,7 @@ class Procedure < ApplicationRecord def publish!(path) now = Time.now - self.update!({ test_started_at: now, published_at: now, archived_at: nil }) + self.update!({ test_started_at: now, published_at: now, archived_at: nil, aasm_state: :publiee }) ProcedurePath.create!(path: path, procedure: self, administrateur: self.administrateur) end @@ -163,7 +163,7 @@ class Procedure < ApplicationRecord end def archive - self.update!(archived_at: Time.now) + self.update!(archived_at: Time.now, aasm_state: :archivee) end def archivee? diff --git a/db/migrate/20180515135415_add_aasm_state_to_procedures.rb b/db/migrate/20180515135415_add_aasm_state_to_procedures.rb new file mode 100644 index 000000000..b290b0c08 --- /dev/null +++ b/db/migrate/20180515135415_add_aasm_state_to_procedures.rb @@ -0,0 +1,5 @@ +class AddAasmStateToProcedures < ActiveRecord::Migration[5.2] + def change + add_column :procedures, :aasm_state, :string, index: true, default: :brouillon + end +end diff --git a/db/schema.rb b/db/schema.rb index 3434709d1..9594d9709 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2018_05_02_092852) do +ActiveRecord::Schema.define(version: 2018_05_15_135415) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -465,6 +465,7 @@ ActiveRecord::Schema.define(version: 2018_05_02_092852) do t.boolean "cloned_from_library", default: false t.bigint "parent_procedure_id" t.datetime "test_started_at" + t.string "aasm_state", default: "brouillon" t.index ["hidden_at"], name: "index_procedures_on_hidden_at" t.index ["parent_procedure_id"], name: "index_procedures_on_parent_procedure_id" end diff --git a/lib/tasks/2018_05_15_add_aasm_state_to_procedure.rake b/lib/tasks/2018_05_15_add_aasm_state_to_procedure.rake new file mode 100644 index 000000000..6fbfdac81 --- /dev/null +++ b/lib/tasks/2018_05_15_add_aasm_state_to_procedure.rake @@ -0,0 +1,8 @@ +namespace :'2018_05_15_add_aasm_state_to_procedure' do + task set: :environment do + Procedure.archivees.update_all(aasm_state: :archivee) + Procedure.publiees.update_all(aasm_state: :publiee) + Procedure.brouillons.update_all(aasm_state: :brouillon) + Procedure.unscoped.where.not(hidden_at: nil).update_all(aasm_state: :hidden) + end +end