From 17c83b1ce2b33e5b17f0b096dc005797e1d04758 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Wed, 16 Feb 2022 18:26:09 +0100 Subject: [PATCH 01/39] mailer: fix notify_new_answer mailer preview --- spec/mailers/previews/dossier_mailer_preview.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/spec/mailers/previews/dossier_mailer_preview.rb b/spec/mailers/previews/dossier_mailer_preview.rb index 739989da3..50dc43835 100644 --- a/spec/mailers/previews/dossier_mailer_preview.rb +++ b/spec/mailers/previews/dossier_mailer_preview.rb @@ -5,7 +5,7 @@ class DossierMailerPreview < ActionMailer::Preview end def notify_new_answer - DossierMailer.notify_new_answer(dossier) + DossierMailer.with(commentaire: commentaire(on: draft)).notify_new_answer end def notify_revert_to_instruction @@ -88,7 +88,7 @@ class DossierMailerPreview < ActionMailer::Preview end def draft - Dossier.new(id: 47882, procedure: procedure, user: user) + Dossier.new(id: 47882, state: :brouillon, procedure: procedure, user: user) end def dossier @@ -119,4 +119,9 @@ class DossierMailerPreview < ActionMailer::Preview def transfer DossierTransfer.new(email: usager_email, dossiers: [dossier, dossier_accepte]) end + + def commentaire(on:) + dossier = on + Commentaire.new(id: 7726, body: "Bonjour, Vous avez commencé le dépôt d’un dossier pour une subvention DETR /DSIL. Dans le cas où votre opération n’aurait pas connu un commencement d’exécution, vous êtes encouragé(e) à redéposer un nouveau dossier sur le formulaire de cette année.\nLa DDT", dossier: dossier) + end end From 3fe2e3b374b687e78de77b8d6d665ccc97e1acd9 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Wed, 16 Feb 2022 17:58:02 +0100 Subject: [PATCH 02/39] mailer: add missing space to notify_new_answer message --- config/locales/views/dossier_mailer/notify_new_answer/fr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/views/dossier_mailer/notify_new_answer/fr.yml b/config/locales/views/dossier_mailer/notify_new_answer/fr.yml index 4e6205abd..80f93c705 100644 --- a/config/locales/views/dossier_mailer/notify_new_answer/fr.yml +++ b/config/locales/views/dossier_mailer/notify_new_answer/fr.yml @@ -7,7 +7,7 @@ fr: link: | Pour consulter le message et y répondre, cliquez sur le bouton ci-dessous : body_draft_html: | - Vous avez reçu un nouveau messagedu service pour lequel votre dossier est en brouillon pour la démarche « %{libelle_demarche} ». + Vous avez reçu un nouveau message du service pour lequel votre dossier est en brouillon pour la démarche « %{libelle_demarche} ». contact: Si vous souhaitez contacter le service, merci de le faire directement à l'aide de l'email en bas de page. access_message: Lire le message access_file: Voir le dossier From 0a1214114e361976699b0bf0ad1c891be031f62e Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Wed, 16 Feb 2022 17:59:02 +0100 Subject: [PATCH 03/39] mailer: re-order notify_new_answer template MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This avoids an `if !…` condition. --- app/views/dossier_mailer/notify_new_answer.html.haml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/dossier_mailer/notify_new_answer.html.haml b/app/views/dossier_mailer/notify_new_answer.html.haml index 6b05e9455..4d90c98e7 100644 --- a/app/views/dossier_mailer/notify_new_answer.html.haml +++ b/app/views/dossier_mailer/notify_new_answer.html.haml @@ -3,16 +3,16 @@ %p= t(:hello, scope: [:views, :shared, :greetings]) -- if !@dossier.brouillon? - %p= t('.body_html', libelle_demarche: @dossier.procedure.libelle) - %p= t('.link') - = round_button(t('.access_message'), messagerie_dossier_url(@dossier), :primary) -- else +- if @dossier.brouillon? %p= t('.body_draft_html', libelle_demarche: @dossier.procedure.libelle) %p{ style: "padding: 8px; color: #333333; background-color: #EEEEEE; font-size: 14px;" } = @body %p= t('.contact') = round_button(t('.access_file'), dossier_url(@dossier), :primary) +- else + %p= t('.body_html', libelle_demarche: @dossier.procedure.libelle) + %p= t('.link') + = round_button(t('.access_message'), messagerie_dossier_url(@dossier), :primary) = render 'layouts/mailers/signature', service: @service From c9f1a2b8ea756e41bfdc7de6a05eb27248f9ba32 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Wed, 16 Feb 2022 17:26:45 +0000 Subject: [PATCH 04/39] mailer: improve notify_new_answer wording And also insert the reply email address directly in the email body. --- app/views/dossier_mailer/notify_new_answer.html.haml | 5 ++++- .../views/dossier_mailer/notify_new_answer/en.yml | 3 ++- .../views/dossier_mailer/notify_new_answer/fr.yml | 7 ++++--- spec/mailers/dossier_mailer_spec.rb | 10 +++++++++- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/app/views/dossier_mailer/notify_new_answer.html.haml b/app/views/dossier_mailer/notify_new_answer.html.haml index 4d90c98e7..8a4a78929 100644 --- a/app/views/dossier_mailer/notify_new_answer.html.haml +++ b/app/views/dossier_mailer/notify_new_answer.html.haml @@ -7,7 +7,10 @@ %p= t('.body_draft_html', libelle_demarche: @dossier.procedure.libelle) %p{ style: "padding: 8px; color: #333333; background-color: #EEEEEE; font-size: 14px;" } = @body - %p= t('.contact') + - if @service&.email.present? + %p= t('.contact_html', email: @service.email) + - else + %p= t('.contact_no_email') = round_button(t('.access_file'), dossier_url(@dossier), :primary) - else %p= t('.body_html', libelle_demarche: @dossier.procedure.libelle) diff --git a/config/locales/views/dossier_mailer/notify_new_answer/en.yml b/config/locales/views/dossier_mailer/notify_new_answer/en.yml index 23a9cfd7d..d066eec9e 100644 --- a/config/locales/views/dossier_mailer/notify_new_answer/en.yml +++ b/config/locales/views/dossier_mailer/notify_new_answer/en.yml @@ -8,6 +8,7 @@ en: To read the message and answer it, select the following link: body_draft_html: | You received a new message from the service in charge of reviewing the file you started a draft for on the procedure « %{libelle_demarche} ». - contact: If you chose to contact the service, please use the email available below in the page. + contact_html: "If you chose to contact the service, please send an email directly to this address: %{email}" + contact_no_email: If you chose to contact the service, please use the contact infos available below. access_message: Read the message access_file: Open file diff --git a/config/locales/views/dossier_mailer/notify_new_answer/fr.yml b/config/locales/views/dossier_mailer/notify_new_answer/fr.yml index 80f93c705..7392b0b07 100644 --- a/config/locales/views/dossier_mailer/notify_new_answer/fr.yml +++ b/config/locales/views/dossier_mailer/notify_new_answer/fr.yml @@ -3,11 +3,12 @@ fr: notify_new_answer: subject: Nouveau message pour votre dossier nº %{dossier_id} « %{libelle_demarche} » body_html: | - Vous avez reçu un nouveau message de la part du service en charge de votre dossier sur la démarche « %{libelle_demarche} ». + Vous avez reçu un nouveau message de la part de l’administration en charge de votre dossier sur la démarche « %{libelle_demarche} ». link: | Pour consulter le message et y répondre, cliquez sur le bouton ci-dessous : body_draft_html: | - Vous avez reçu un nouveau message du service pour lequel votre dossier est en brouillon pour la démarche « %{libelle_demarche} ». - contact: Si vous souhaitez contacter le service, merci de le faire directement à l'aide de l'email en bas de page. + Vous avez reçu un nouveau message de l’administration, au sujet de votre dossier en brouillon pour la démarche « %{libelle_demarche} ». + contact_html: "Si vous souhaitez répondre à ce message, contactez directement l’administration à l’adresse suivante : %{email}" + contact_no_email: Si vous souhaitez répondre à ce message, contactez directement l’administration à l’aide des coordonnées en bas de cet email. access_message: Lire le message access_file: Voir le dossier diff --git a/spec/mailers/dossier_mailer_spec.rb b/spec/mailers/dossier_mailer_spec.rb index 31d3ab633..9c8b39b48 100644 --- a/spec/mailers/dossier_mailer_spec.rb +++ b/spec/mailers/dossier_mailer_spec.rb @@ -27,15 +27,23 @@ RSpec.describe DossierMailer, type: :mailer do end describe '.notify_new_answer with dossier brouillon' do - let(:dossier) { create(:dossier, procedure: create(:simple_procedure)) } + let(:service) { build(:service) } + let(:procedure) { create(:simple_procedure, service: service) } + let(:dossier) { create(:dossier, procedure: procedure) } let(:commentaire) { create(:commentaire, dossier: dossier) } subject { described_class.with(commentaire: commentaire).notify_new_answer } it { expect(subject.subject).to include("Nouveau message") } it { expect(subject.subject).to include(dossier.id.to_s) } + it { expect(subject.body).to include(dossier.procedure.service.email) } it { expect(subject.body).not_to include(messagerie_dossier_url(dossier)) } it_behaves_like 'a dossier notification' + + context 'when there is no associated service' do + let(:service) { nil } + it { expect { subject }.not_to raise_error } + end end describe '.notify_new_answer with dossier en construction' do From 50f095a5c6d2ea6b487b04144307597ad26057ae Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Thu, 17 Feb 2022 14:35:29 +0100 Subject: [PATCH 05/39] test(user): fix unstable spec --- spec/models/user_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index c008fb065..7a74f0e2e 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -433,7 +433,7 @@ describe User, type: :model do it 'transfers the dossier' do subject - expect(targeted_user.dossiers.with_discarded).to match([dossier, hidden_dossier]) + expect(targeted_user.dossiers.with_discarded).to contain_exactly(dossier, hidden_dossier) expect(targeted_user.invites).to match([invite]) expect(targeted_user.merge_logs.first).to eq(merge_log) From 2d396fcfb771323ce370b810d7811e6a2cb1f84e Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Fri, 11 Feb 2022 18:23:46 +0100 Subject: [PATCH 06/39] feat(dossier): rebase dossiers en construction and en instruction --- app/models/concerns/dossier_rebase_concern.rb | 46 +++++- app/models/procedure.rb | 6 +- spec/models/dossier_spec.rb | 152 ++++++++++++++++++ spec/models/procedure_spec.rb | 6 +- 4 files changed, 202 insertions(+), 8 deletions(-) diff --git a/app/models/concerns/dossier_rebase_concern.rb b/app/models/concerns/dossier_rebase_concern.rb index 1117b7ebe..bdfb04186 100644 --- a/app/models/concerns/dossier_rebase_concern.rb +++ b/app/models/concerns/dossier_rebase_concern.rb @@ -2,19 +2,57 @@ module DossierRebaseConcern extend ActiveSupport::Concern def rebase! - if brouillon? && revision != procedure.published_revision + if can_rebase? transaction do rebase end end end + def can_rebase? + revision != procedure.published_revision && + (brouillon? || accepted_en_construction_changes? || accepted_en_instruction_changes?) + end + + def pending_changes + revision.compare(procedure.published_revision) + end + private + def accepted_en_construction_changes? + en_construction? && pending_changes.all? { |change| accepted_en_construction_change?(change) } + end + + def accepted_en_instruction_changes? + en_instruction? && pending_changes.all? { |change| accepted_en_instruction_change?(change) } + end + + def accepted_en_construction_change?(change) + if change[:model] == :attestation_template || change[:op] == :move || change[:op] == :remove + true + elsif change[:op] == :update + case change[:attribute] + when :carte_layers + true + when :mandatory + change[:from] && !change[:to] + else + false + end + else + false + end + end + + def accepted_en_instruction_change?(change) + change[:model] == :attestation_template + end + def rebase attachments_to_purge = [] geo_areas_to_delete = [] - changes_by_type_de_champ = revision.compare(procedure.published_revision) + changes_by_type_de_champ = pending_changes .filter { |change| change[:model] == :type_de_champ } .group_by { |change| change[:stable_id] } @@ -51,7 +89,9 @@ module DossierRebaseConcern when :drop_down_options update[:value] = nil when :carte_layers - geo_areas_to_delete += champ.geo_areas + if change[:from].include?(:cadastres) && !change[:to].include?(:cadastres) + geo_areas_to_delete += champ.cadastres + end end update[:rebased_at] = Time.zone.now end diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 06741df9b..ff8b74fbd 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -738,9 +738,9 @@ class Procedure < ApplicationRecord def publish_revision! update!(draft_revision: create_new_revision, published_revision: draft_revision) published_revision.touch(:published_at) - dossiers.state_brouillon.find_each do |dossier| - DossierRebaseJob.perform_later(dossier) - end + dossiers + .state_not_termine + .find_each { |dossier| DossierRebaseJob.perform_later(dossier) } end def cnaf_enabled? diff --git a/spec/models/dossier_spec.rb b/spec/models/dossier_spec.rb index 6026e6b9e..e5533c1f8 100644 --- a/spec/models/dossier_spec.rb +++ b/spec/models/dossier_spec.rb @@ -1573,6 +1573,158 @@ describe Dossier do it { expect(dossier.spreadsheet_columns(types_de_champ: [])).to include(["État du dossier", "Brouillon"]) } end + describe '#can_rebase?' do + let(:procedure) { create(:procedure, :with_type_de_champ_mandatory, :with_yes_no, attestation_template: build(:attestation_template)) } + let(:attestation_template) { procedure.draft_revision.attestation_template.find_or_revise! } + let(:type_de_champ) { procedure.types_de_champ.find { |tdc| !tdc.mandatory? } } + let(:mandatory_type_de_champ) { procedure.types_de_champ.find(&:mandatory?) } + + before { Flipper.enable(:procedure_revisions, procedure) } + + context 'en_construction' do + let(:dossier) { create(:dossier, :en_construction, procedure: procedure) } + + before do + procedure.publish! + procedure.reload + dossier + end + + context 'with added type de champ' do + before do + procedure.draft_revision.add_type_de_champ({ + type_champ: TypeDeChamp.type_champs.fetch(:text), + libelle: "Un champ text" + }) + procedure.publish_revision! + dossier.reload + end + + it 'should be false' do + expect(dossier.pending_changes).not_to be_empty + expect(dossier.can_rebase?).to be_falsey + end + end + + context 'with type de champ made optional' do + before do + procedure.draft_revision.find_or_clone_type_de_champ(mandatory_type_de_champ.stable_id).update(mandatory: false) + procedure.publish_revision! + dossier.reload + end + + it 'should be true' do + expect(dossier.pending_changes).not_to be_empty + expect(dossier.can_rebase?).to be_truthy + end + end + + context 'with type de champ made mandatory' do + before do + procedure.draft_revision.find_or_clone_type_de_champ(type_de_champ.stable_id).update(mandatory: true) + procedure.publish_revision! + dossier.reload + end + + it 'should be false' do + expect(dossier.pending_changes).not_to be_empty + expect(dossier.can_rebase?).to be_falsey + end + end + + context 'with removed type de champ' do + before do + procedure.draft_revision.remove_type_de_champ(type_de_champ.stable_id) + procedure.publish_revision! + dossier.reload + end + + it 'should be true' do + expect(dossier.pending_changes).not_to be_empty + expect(dossier.can_rebase?).to be_truthy + end + end + + context 'with attestation template changes' do + before do + attestation_template.update(title: "Test") + procedure.publish_revision! + dossier.reload + end + + it 'should be true' do + expect(dossier.pending_changes).not_to be_empty + expect(dossier.can_rebase?).to be_truthy + end + end + end + + context 'en_instruction' do + let(:dossier) { create(:dossier, :en_instruction, procedure: procedure) } + + before do + procedure.publish! + procedure.reload + dossier + end + + context 'with added type de champ' do + before do + procedure.draft_revision.add_type_de_champ({ + type_champ: TypeDeChamp.type_champs.fetch(:text), + libelle: "Un champ text" + }) + procedure.publish_revision! + dossier.reload + end + + it 'should be false' do + expect(dossier.pending_changes).not_to be_empty + expect(dossier.can_rebase?).to be_falsey + end + end + + context 'with removed type de champ' do + before do + procedure.draft_revision.remove_type_de_champ(type_de_champ.stable_id) + procedure.publish_revision! + dossier.reload + end + + it 'should be false' do + expect(dossier.pending_changes).not_to be_empty + expect(dossier.can_rebase?).to be_falsey + end + end + + context 'with attestation template changes' do + before do + attestation_template.update(title: "Test") + procedure.publish_revision! + dossier.reload + end + + it 'should be true' do + expect(dossier.pending_changes).not_to be_empty + expect(dossier.can_rebase?).to be_truthy + end + end + + context 'with type de champ made optional' do + before do + procedure.draft_revision.find_or_clone_type_de_champ(mandatory_type_de_champ.stable_id).update(mandatory: false) + procedure.publish_revision! + dossier.reload + end + + it 'should be false' do + expect(dossier.pending_changes).not_to be_empty + expect(dossier.can_rebase?).to be_falsey + end + end + end + end + describe "#rebase" do let(:procedure) { create(:procedure, :with_type_de_champ_mandatory, :with_yes_no, :with_repetition, :with_datetime) } let(:dossier) { create(:dossier, procedure: procedure) } diff --git a/spec/models/procedure_spec.rb b/spec/models/procedure_spec.rb index 88f2b04e4..9bd6e6e85 100644 --- a/spec/models/procedure_spec.rb +++ b/spec/models/procedure_spec.rb @@ -825,13 +825,15 @@ describe Procedure do context 'when the procedure has dossiers' do let(:dossier_draft) { create(:dossier, :brouillon, procedure: procedure) } let(:dossier_submitted) { create(:dossier, :en_construction, procedure: procedure) } + let(:dossier_termine) { create(:dossier, :accepte, procedure: procedure) } - before { [dossier_draft, dossier_submitted] } + before { [dossier_draft, dossier_submitted, dossier_termine] } it 'enqueues rebase jobs for draft dossiers' do subject expect(DossierRebaseJob).to have_been_enqueued.with(dossier_draft) - expect(DossierRebaseJob).not_to have_been_enqueued.with(dossier_submitted) + expect(DossierRebaseJob).to have_been_enqueued.with(dossier_submitted) + expect(DossierRebaseJob).not_to have_been_enqueued.with(dossier_termine) end end end From e0bf1ea8cf7ed37070a472e844efdc1ffb777783 Mon Sep 17 00:00:00 2001 From: kreushed Date: Fri, 14 Jan 2022 13:34:45 +0100 Subject: [PATCH 07/39] Mise a jour des images --- app/assets/images/login-with-fc-hover.svg | 2 +- app/assets/images/login-with-fc.svg | 2 +- app/assets/stylesheets/france-connect-login.scss | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/assets/images/login-with-fc-hover.svg b/app/assets/images/login-with-fc-hover.svg index 2a580527e..5a2d16909 100644 --- a/app/assets/images/login-with-fc-hover.svg +++ b/app/assets/images/login-with-fc-hover.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/app/assets/images/login-with-fc.svg b/app/assets/images/login-with-fc.svg index afc1e8d89..3a95ff212 100644 --- a/app/assets/images/login-with-fc.svg +++ b/app/assets/images/login-with-fc.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/app/assets/stylesheets/france-connect-login.scss b/app/assets/stylesheets/france-connect-login.scss index f54289631..20c66f404 100644 --- a/app/assets/stylesheets/france-connect-login.scss +++ b/app/assets/stylesheets/france-connect-login.scss @@ -15,8 +15,8 @@ .france-connect-login-button { display: inline-block; - height: 52px; - width: 186px; + height: 60px; + width: 230px; margin: auto; margin-bottom: 8px; background-image: image-url("login-with-fc.svg"), image-url("login-with-fc-hover.svg"); From 167cb100b62f8694e42a8f5032414d5f7da53ae2 Mon Sep 17 00:00:00 2001 From: kreushed Date: Fri, 14 Jan 2022 14:35:30 +0100 Subject: [PATCH 08/39] Mise a jour du volet droit de la page session new --- app/assets/stylesheets/auth.scss | 7 +++++++ app/views/shared/_france_connect_login.html.haml | 2 +- app/views/users/sessions/new.html.haml | 14 +++++--------- config/locales/en.yml | 6 +++--- config/locales/fr.yml | 6 +++--- 5 files changed, 19 insertions(+), 16 deletions(-) diff --git a/app/assets/stylesheets/auth.scss b/app/assets/stylesheets/auth.scss index 4cc36d96e..492811b92 100644 --- a/app/assets/stylesheets/auth.scss +++ b/app/assets/stylesheets/auth.scss @@ -61,3 +61,10 @@ margin-bottom: 0; } } + +#session-new { + .important-header { + font-weight: bold; + font-size: 18px; + } +} diff --git a/app/views/shared/_france_connect_login.html.haml b/app/views/shared/_france_connect_login.html.haml index 9b1b9794c..4279ff2d7 100644 --- a/app/views/shared/_france_connect_login.html.haml +++ b/app/views/shared/_france_connect_login.html.haml @@ -1,6 +1,6 @@ - if FranceConnectService.enabled? .france-connect-login - %h2 + %h2.important-header = t('views.shared.france_connect_login.title') %p = t('views.shared.france_connect_login.description') diff --git a/app/views/users/sessions/new.html.haml b/app/views/users/sessions/new.html.haml index 5e72e1f9b..126a72d42 100644 --- a/app/views/users/sessions/new.html.haml +++ b/app/views/users/sessions/new.html.haml @@ -1,6 +1,6 @@ = content_for(:page_id, 'auth') -.auth-form.sign-in-form +#session-new.auth-form.sign-in-form = form_for resource, url: user_session_path, html: { class: "form" } do |f| %h1.huge-title= t('views.users.sessions.new.sign_in') @@ -27,11 +27,7 @@ = t('views.shared.france_connect_login.separator') - if AgentConnectService.enabled? .center - %p.mb-2= t('views.users.sessions.new.instructor_or_admin') - = link_to t('views.users.sessions.new.connect_with_agent_connect'), agent_connect_path - %hr - %p.center - %span= t('views.users.sessions.new.are_you_new', app_name: APPLICATION_NAME.gsub("-","‑")).html_safe - %br - %br - = link_to t('views.users.sessions.new.find_procedure'), COMMENT_TROUVER_MA_DEMARCHE_URL, target: "_blank", class: "button expend secondary" + %h2.important-header= t('views.users.sessions.new.state_civil_servant') + %br + %br + = link_to t('views.users.sessions.new.connect_with_agent_connect'), agent_connect_path, class: "button expend secondary" diff --git a/config/locales/en.yml b/config/locales/en.yml index ce5d296d0..01e989b67 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -56,6 +56,7 @@ en: line1: A simple tool line2: to manage dematerialized line3: administrative forms. + are_you_new: First time on %{app_name}? locale_dropdown: languages: "Languages" notifications: @@ -215,10 +216,9 @@ en: remember_me: Remember me reset_password: Forgot password? connection: Sign in - are_you_new: First time on %{app_name}? find_procedure: Find your procedure - instructor_or_admin: Instructor or Administrator ? - connect_with_agent_connect: Connect with AgentConnect + state_civil_servant: Are you a state civil servant? + connect_with_agent_connect: Visit our dedicated page passwords: reset_link_sent: got_it: Got it! diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 194de98b7..f7075dd1d 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -47,6 +47,7 @@ fr: line1: Un outil simple line2: pour gérer les formulaires line3: administratifs dématérialisés. + are_you_new: Vous êtes nouveau sur %{app_name} ? locale_dropdown: languages: "Langues" notifications: @@ -212,10 +213,9 @@ fr: remember_me: Se souvenir de moi reset_password: Mot de passe oublié ? connection: Se connecter - are_you_new: Vous êtes nouveau sur %{app_name} ? find_procedure: Trouvez votre démarche - instructor_or_admin: Vous êtes instructeur ou administrateur ? - connect_with_agent_connect: Se connecter avec AgentConnect + state_civil_servant: Vous êtes agent de la fonction publique d’État ? + connect_with_agent_connect: Accédez à notre page dédiée passwords: reset_link_sent: email_sent_html: "Nous vous avons envoyé un email à l’adresse %{email}." From 1c5b1c0030f69893ed9353804b35a689bf0be18b Mon Sep 17 00:00:00 2001 From: kreushed Date: Fri, 14 Jan 2022 14:55:28 +0100 Subject: [PATCH 09/39] Mise a jour du volet gauche de la page session new --- app/assets/stylesheets/procedure_context.scss | 6 ++++++ app/views/layouts/commencer/_no_procedure.html.haml | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/app/assets/stylesheets/procedure_context.scss b/app/assets/stylesheets/procedure_context.scss index 5cc67ad4d..24f600222 100644 --- a/app/assets/stylesheets/procedure_context.scss +++ b/app/assets/stylesheets/procedure_context.scss @@ -22,6 +22,12 @@ $procedure-description-line-height: 22px; font-weight: bold; } + .small-simple { + font-size: 16px; + color: $blue-france-500; + font-weight: bold; + } + .close-procedure { font-size: 12px; } diff --git a/app/views/layouts/commencer/_no_procedure.html.haml b/app/views/layouts/commencer/_no_procedure.html.haml index 50037d4ad..d8be7b199 100644 --- a/app/views/layouts/commencer/_no_procedure.html.haml +++ b/app/views/layouts/commencer/_no_procedure.html.haml @@ -7,3 +7,8 @@ = t('.line2') %br = t('.line3') + %hr + %span.small-simple= t('.are_you_new', app_name: APPLICATION_NAME.gsub("-","‑")).html_safe + %br + %br + = link_to t('views.users.sessions.new.find_procedure'), COMMENT_TROUVER_MA_DEMARCHE_URL, target: "_blank", class: "button expend secondary" From 6930ddb43374dd4cd976b9c94e1c8a196dfd62de Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Mon, 21 Feb 2022 17:25:39 +0100 Subject: [PATCH 10/39] bump rails --- Gemfile.lock | 118 +++++++++++++++++++++++++-------------------------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 74daed95a..12f726dcc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -21,40 +21,40 @@ GEM aasm (5.2.0) concurrent-ruby (~> 1.0) acsv (0.0.1) - actioncable (6.1.4.4) - actionpack (= 6.1.4.4) - activesupport (= 6.1.4.4) + actioncable (6.1.4.6) + actionpack (= 6.1.4.6) + activesupport (= 6.1.4.6) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.1.4.4) - actionpack (= 6.1.4.4) - activejob (= 6.1.4.4) - activerecord (= 6.1.4.4) - activestorage (= 6.1.4.4) - activesupport (= 6.1.4.4) + actionmailbox (6.1.4.6) + actionpack (= 6.1.4.6) + activejob (= 6.1.4.6) + activerecord (= 6.1.4.6) + activestorage (= 6.1.4.6) + activesupport (= 6.1.4.6) mail (>= 2.7.1) - actionmailer (6.1.4.4) - actionpack (= 6.1.4.4) - actionview (= 6.1.4.4) - activejob (= 6.1.4.4) - activesupport (= 6.1.4.4) + actionmailer (6.1.4.6) + actionpack (= 6.1.4.6) + actionview (= 6.1.4.6) + activejob (= 6.1.4.6) + activesupport (= 6.1.4.6) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (6.1.4.4) - actionview (= 6.1.4.4) - activesupport (= 6.1.4.4) + actionpack (6.1.4.6) + actionview (= 6.1.4.6) + activesupport (= 6.1.4.6) rack (~> 2.0, >= 2.0.9) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.1.4.4) - actionpack (= 6.1.4.4) - activerecord (= 6.1.4.4) - activestorage (= 6.1.4.4) - activesupport (= 6.1.4.4) + actiontext (6.1.4.6) + actionpack (= 6.1.4.6) + activerecord (= 6.1.4.6) + activestorage (= 6.1.4.6) + activesupport (= 6.1.4.6) nokogiri (>= 1.8.5) - actionview (6.1.4.4) - activesupport (= 6.1.4.4) + actionview (6.1.4.6) + activesupport (= 6.1.4.6) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) @@ -72,26 +72,26 @@ GEM activemodel (>= 5.2.0) activestorage (>= 5.2.0) activesupport (>= 5.2.0) - activejob (6.1.4.4) - activesupport (= 6.1.4.4) + activejob (6.1.4.6) + activesupport (= 6.1.4.6) globalid (>= 0.3.6) - activemodel (6.1.4.4) - activesupport (= 6.1.4.4) - activerecord (6.1.4.4) - activemodel (= 6.1.4.4) - activesupport (= 6.1.4.4) - activestorage (6.1.4.4) - actionpack (= 6.1.4.4) - activejob (= 6.1.4.4) - activerecord (= 6.1.4.4) - activesupport (= 6.1.4.4) + activemodel (6.1.4.6) + activesupport (= 6.1.4.6) + activerecord (6.1.4.6) + activemodel (= 6.1.4.6) + activesupport (= 6.1.4.6) + activestorage (6.1.4.6) + actionpack (= 6.1.4.6) + activejob (= 6.1.4.6) + activerecord (= 6.1.4.6) + activesupport (= 6.1.4.6) marcel (~> 1.0.0) mini_mime (>= 1.1.0) activestorage-openstack (1.5.1) fog-openstack (~> 1.0) marcel rails (>= 5.2.2) - activesupport (6.1.4.4) + activesupport (6.1.4.6) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -351,7 +351,7 @@ GEM domain_name (~> 0.5) http_accept_language (2.1.1) httpclient (2.8.3) - i18n (1.8.11) + i18n (1.10.0) concurrent-ruby (~> 1.0) i18n-tasks (0.9.33) activesupport (>= 4.0.2) @@ -417,7 +417,7 @@ GEM railties (>= 4) request_store (~> 1.0) logstash-event (1.2.02) - loofah (2.13.0) + loofah (2.14.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) @@ -433,7 +433,7 @@ GEM mime-types-data (3.2021.0212) mini_magick (4.11.0) mini_mime (1.1.2) - mini_portile2 (2.6.1) + mini_portile2 (2.7.1) minitest (5.15.0) momentjs-rails (2.20.1) railties (>= 3.1) @@ -444,8 +444,8 @@ GEM ruby2_keywords (~> 0.0.1) netrc (0.11.0) nio4r (2.5.8) - nokogiri (1.12.5) - mini_portile2 (~> 2.6.1) + nokogiri (1.13.1) + mini_portile2 (~> 2.7.0) racc (~> 1.4) open4 (1.3.4) openid_connect (1.3.0) @@ -515,20 +515,20 @@ GEM rack rack-test (1.1.0) rack (>= 1.0, < 3) - rails (6.1.4.4) - actioncable (= 6.1.4.4) - actionmailbox (= 6.1.4.4) - actionmailer (= 6.1.4.4) - actionpack (= 6.1.4.4) - actiontext (= 6.1.4.4) - actionview (= 6.1.4.4) - activejob (= 6.1.4.4) - activemodel (= 6.1.4.4) - activerecord (= 6.1.4.4) - activestorage (= 6.1.4.4) - activesupport (= 6.1.4.4) + rails (6.1.4.6) + actioncable (= 6.1.4.6) + actionmailbox (= 6.1.4.6) + actionmailer (= 6.1.4.6) + actionpack (= 6.1.4.6) + actiontext (= 6.1.4.6) + actionview (= 6.1.4.6) + activejob (= 6.1.4.6) + activemodel (= 6.1.4.6) + activerecord (= 6.1.4.6) + activestorage (= 6.1.4.6) + activesupport (= 6.1.4.6) bundler (>= 1.15.0) - railties (= 6.1.4.4) + railties (= 6.1.4.6) sprockets-rails (>= 2.0.0) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) @@ -547,9 +547,9 @@ GEM rails-i18n (6.0.0) i18n (>= 0.7, < 2) railties (>= 6.0.0, < 7) - railties (6.1.4.4) - actionpack (= 6.1.4.4) - activesupport (= 6.1.4.4) + railties (6.1.4.6) + actionpack (= 6.1.4.6) + activesupport (= 6.1.4.6) method_source rake (>= 0.13) thor (~> 1.0) @@ -768,7 +768,7 @@ GEM websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.5.3) + zeitwerk (2.5.4) zip_tricks (5.6.0) zxcvbn-ruby (1.2.0) From e6ad411aaeff4aa79db16b4b194a5ef29828086e Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Fri, 18 Feb 2022 10:09:22 +0100 Subject: [PATCH 11/39] gems: remove hardcoded version for `zipline` The fix was eventually released. --- Gemfile | 2 +- Gemfile.lock | 16 ++++++---------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/Gemfile b/Gemfile index b56231cea..c556098c7 100644 --- a/Gemfile +++ b/Gemfile @@ -83,7 +83,7 @@ gem 'spreadsheet_architect' gem 'typhoeus' gem 'warden' gem 'webpacker' -gem 'zipline', github: 'fringd/zipline', ref: 'd637bbff2' # Unreleased 1.3.0, with a fix for Ruby 3.0 kwargs +gem 'zipline' gem 'zxcvbn-ruby', require: 'zxcvbn' group :test do diff --git a/Gemfile.lock b/Gemfile.lock index 12f726dcc..a845960d8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,12 +1,3 @@ -GIT - remote: https://github.com/fringd/zipline.git - revision: d637bbff262f59718d23a65f50b50163b8ba749f - ref: d637bbff2 - specs: - zipline (1.3.0) - actionpack (>= 3.2.1, < 7.0) - zip_tricks (>= 4.2.1, < 6.0) - GIT remote: https://github.com/mina-deploy/mina.git revision: 84fa84c7f7f94f9518ef9b7099396ab6676b5881 @@ -183,6 +174,7 @@ GEM descendants_tracker (~> 0.0.1) concurrent-ruby (1.1.9) connection_pool (2.2.3) + content_disposition (1.0.0) crack (0.4.5) rexml crass (1.0.6) @@ -770,6 +762,10 @@ GEM nokogiri (~> 1.8) zeitwerk (2.5.4) zip_tricks (5.6.0) + zipline (1.4.1) + actionpack (>= 6.0, < 8.0) + content_disposition (~> 1.0) + zip_tricks (>= 4.2.1, < 6.0) zxcvbn-ruby (1.2.0) PLATFORMS @@ -892,7 +888,7 @@ DEPENDENCIES webdrivers (~> 4.0) webmock webpacker - zipline! + zipline zxcvbn-ruby BUNDLED WITH From 4cde3623be410509e879bcb9950373ad2540b3ae Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Fri, 18 Feb 2022 10:10:15 +0100 Subject: [PATCH 12/39] gems: remove hardcoded git URL for `mina` It is not needed anymore. --- Gemfile | 2 +- Gemfile.lock | 13 ++++--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Gemfile b/Gemfile index c556098c7..0a5ce4a84 100644 --- a/Gemfile +++ b/Gemfile @@ -120,7 +120,7 @@ end group :development, :test do gem 'graphql-schema_comparator' - gem 'mina', git: 'https://github.com/mina-deploy/mina.git', require: false # Deploy + gem 'mina', require: false # Deploy gem 'pry-byebug' # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'rspec-rails' gem 'simple_xlsx_reader' diff --git a/Gemfile.lock b/Gemfile.lock index a845960d8..50bdda94b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,11 +1,3 @@ -GIT - remote: https://github.com/mina-deploy/mina.git - revision: 84fa84c7f7f94f9518ef9b7099396ab6676b5881 - specs: - mina (1.2.3) - open4 (~> 1.3.4) - rake - GEM remote: https://rubygems.org/ specs: @@ -423,6 +415,9 @@ GEM mime-types (3.3.1) mime-types-data (~> 3.2015) mime-types-data (3.2021.0212) + mina (1.2.4) + open4 (~> 1.3.4) + rake mini_magick (4.11.0) mini_mime (1.1.2) mini_portile2 (2.7.1) @@ -838,7 +833,7 @@ DEPENDENCIES lograge logstash-event mailjet - mina! + mina openid_connect pg phonelib From 30d7cf634a24edad18d76b5f936a0c3260832c95 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Tue, 22 Feb 2022 09:21:35 +0100 Subject: [PATCH 13/39] tasks: restore older after_party tasks Turns out deleting the tasks after 6 months only may not be enough for instances deploying only once a year, for instance. This reverts commit 77b65f3aa0d9cc0c9125d83aa2d70c892634a62d. --- ...200326133630_cleanup_deleted_dossiers.rake | 10 +++ ...cess_expired_dossiers_en_construction.rake | 27 +++++++ ...0200527124112_fix_champ_etablissement.rake | 35 +++++++++ ...00528124044_fix_dossier_etablissement.rake | 20 ++++++ ...121241_drop_down_list_options_to_json.rake | 25 +++++++ .../20200625113026_migrate_revisions.rake | 22 ++++++ ...0154829_add_traitements_from_dossiers.rake | 18 +++++ ...kip_validation_to_piece_justificative.rake | 18 +++++ .../20200728150458_fix_cloned_revisions.rake | 25 +++++++ ...20200813111957_fix_geo_areas_geometry.rake | 71 +++++++++++++++++++ ...1931_migrate_filters_to_use_stable_id.rake | 50 +++++++++++++ .../20201006123842_setup_first_stats.rake | 11 +++ ...18163035_fix_types_de_champ_revisions.rake | 19 +++++ ...dation_to_piece_justificative.rake_spec.rb | 25 +++++++ ...1_migrate_filters_to_use_stable_id_spec.rb | 60 ++++++++++++++++ 15 files changed, 436 insertions(+) create mode 100644 lib/tasks/deployment/20200326133630_cleanup_deleted_dossiers.rake create mode 100644 lib/tasks/deployment/20200401123317_process_expired_dossiers_en_construction.rake create mode 100644 lib/tasks/deployment/20200527124112_fix_champ_etablissement.rake create mode 100644 lib/tasks/deployment/20200528124044_fix_dossier_etablissement.rake create mode 100644 lib/tasks/deployment/20200618121241_drop_down_list_options_to_json.rake create mode 100644 lib/tasks/deployment/20200625113026_migrate_revisions.rake create mode 100644 lib/tasks/deployment/20200630154829_add_traitements_from_dossiers.rake create mode 100644 lib/tasks/deployment/20200708101123_add_default_skip_validation_to_piece_justificative.rake create mode 100644 lib/tasks/deployment/20200728150458_fix_cloned_revisions.rake create mode 100644 lib/tasks/deployment/20200813111957_fix_geo_areas_geometry.rake create mode 100644 lib/tasks/deployment/20201001161931_migrate_filters_to_use_stable_id.rake create mode 100644 lib/tasks/deployment/20201006123842_setup_first_stats.rake create mode 100644 lib/tasks/deployment/20201218163035_fix_types_de_champ_revisions.rake create mode 100644 spec/lib/tasks/deployment/20200708101123_add_default_skip_validation_to_piece_justificative.rake_spec.rb create mode 100644 spec/lib/tasks/deployment/20201001161931_migrate_filters_to_use_stable_id_spec.rb diff --git a/lib/tasks/deployment/20200326133630_cleanup_deleted_dossiers.rake b/lib/tasks/deployment/20200326133630_cleanup_deleted_dossiers.rake new file mode 100644 index 000000000..64bdb9bdb --- /dev/null +++ b/lib/tasks/deployment/20200326133630_cleanup_deleted_dossiers.rake @@ -0,0 +1,10 @@ +namespace :after_party do + desc 'Deployment task: cleanup_deleted_dossiers' + task cleanup_deleted_dossiers: :environment do + puts "Running deploy task 'cleanup_deleted_dossiers'" + + DeletedDossier.where(state: :brouillon).destroy_all + + AfterParty::TaskRecord.create version: '20200326133630' + end +end diff --git a/lib/tasks/deployment/20200401123317_process_expired_dossiers_en_construction.rake b/lib/tasks/deployment/20200401123317_process_expired_dossiers_en_construction.rake new file mode 100644 index 000000000..cf7113c98 --- /dev/null +++ b/lib/tasks/deployment/20200401123317_process_expired_dossiers_en_construction.rake @@ -0,0 +1,27 @@ +namespace :after_party do + desc 'Deployment task: process_expired_dossiers_en_construction' + task process_expired_dossiers_en_construction: :environment do + puts "Running deploy task 'process_expired_dossiers_en_construction'" + + if ENV['APP_NAME'] == 'tps' + dossiers_close_to_expiration = Dossier + .en_construction_close_to_expiration + .without_en_construction_expiration_notice_sent + + ExpiredDossiersDeletionService.send_expiration_notices(dossiers_close_to_expiration) + + BATCH_SIZE = 1000 + + ((dossiers_close_to_expiration.count / BATCH_SIZE).ceil + 1).times do |n| + dossiers_close_to_expiration + .offset(n * BATCH_SIZE) + .limit(BATCH_SIZE) + .update_all(en_construction_close_to_expiration_notice_sent_at: Time.zone.now + n.days) + end + end + + # Update task as completed. If you remove the line below, the task will + # run with every deploy (or every time you call after_party:run). + AfterParty::TaskRecord.create version: '20200401123317' + end +end diff --git a/lib/tasks/deployment/20200527124112_fix_champ_etablissement.rake b/lib/tasks/deployment/20200527124112_fix_champ_etablissement.rake new file mode 100644 index 000000000..e8e011970 --- /dev/null +++ b/lib/tasks/deployment/20200527124112_fix_champ_etablissement.rake @@ -0,0 +1,35 @@ +namespace :after_party do + desc 'Deployment task: fix_champ_etablissement' + task fix_champ_etablissement: :environment do + puts "Running deploy task 'fix_champ_etablissement'" + + etablissements = Etablissement.joins(:champ).where.not(dossier_id: nil).where('etablissements.created_at > ?', 1.month.ago) + dossiers_modif = [] + etablissements.find_each do |e| + if e.dossier + user = e.dossier.user + dossier = e.dossier + if user.dossiers.count == 1 && user.siret == e.champ.value + e.update!(dossier_id: nil) + dossier.reload.etablissement = e.reload.dup + dossier.save! + dossiers_modif << dossier.id + fetch_api_entreprise_infos(dossier.etablissement.id, dossier.procedure.id, user.id) + end + end + end + puts "Nb dossiers modifiés: #{dossiers_modif.size}" + AfterParty::TaskRecord.create version: '20200527124112' + end + + def fetch_api_entreprise_infos(etablissement_id, procedure_id, user_id) + [ + APIEntreprise::EntrepriseJob, APIEntreprise::AssociationJob, APIEntreprise::ExercicesJob, + APIEntreprise::EffectifsJob, APIEntreprise::EffectifsAnnuelsJob, APIEntreprise::AttestationSocialeJob, + APIEntreprise::BilansBdfJob + ].each do |job| + job.perform_later(etablissement_id, procedure_id) + end + APIEntreprise::AttestationFiscaleJob.perform_later(etablissement_id, procedure_id, user_id) + end +end diff --git a/lib/tasks/deployment/20200528124044_fix_dossier_etablissement.rake b/lib/tasks/deployment/20200528124044_fix_dossier_etablissement.rake new file mode 100644 index 000000000..3df50df86 --- /dev/null +++ b/lib/tasks/deployment/20200528124044_fix_dossier_etablissement.rake @@ -0,0 +1,20 @@ +namespace :after_party do + desc 'Deployment task: fix_dossier_etablissement' + task fix_dossier_etablissement: :environment do + puts "Running deploy task 'fix_dossier_etablissement'" + + etablissements = Etablissement.joins(:champ).where.not(dossier_id: nil).where('etablissements.created_at > ?', 1.month.ago) + dossiers_modif = [] + etablissements.find_each do |e| + if e.dossier + dossier = e.dossier + e.update!(dossier_id: nil) + dossier.reload.etablissement = e.reload.dup + dossier.save! + dossiers_modif << dossier.id + end + end + puts "Nb dossiers modifiés: #{dossiers_modif.size}" + AfterParty::TaskRecord.create version: '20200528124044' + end +end diff --git a/lib/tasks/deployment/20200618121241_drop_down_list_options_to_json.rake b/lib/tasks/deployment/20200618121241_drop_down_list_options_to_json.rake new file mode 100644 index 000000000..a96758e98 --- /dev/null +++ b/lib/tasks/deployment/20200618121241_drop_down_list_options_to_json.rake @@ -0,0 +1,25 @@ +namespace :after_party do + desc 'Deployment task: drop_down_list_options_to_json' + task drop_down_list_options_to_json: :environment do + puts "Running deploy task 'drop_down_list_options_to_json'" + + types_de_champ = TypeDeChamp.joins(:drop_down_list).where(type_champ: [ + TypeDeChamp.type_champs.fetch(:drop_down_list), + TypeDeChamp.type_champs.fetch(:multiple_drop_down_list), + TypeDeChamp.type_champs.fetch(:linked_drop_down_list) + ]) + progress = ProgressReport.new(types_de_champ.count) + types_de_champ.find_each do |type_de_champ| + type_de_champ.drop_down_list_value = type_de_champ.drop_down_list_value + if type_de_champ.save + type_de_champ.drop_down_list.destroy + end + progress.inc + end + progress.finish + + # Update task as completed. If you remove the line below, the task will + # run with every deploy (or every time you call after_party:run). + AfterParty::TaskRecord.create version: '20200618121241' + end +end diff --git a/lib/tasks/deployment/20200625113026_migrate_revisions.rake b/lib/tasks/deployment/20200625113026_migrate_revisions.rake new file mode 100644 index 000000000..ffa7c986b --- /dev/null +++ b/lib/tasks/deployment/20200625113026_migrate_revisions.rake @@ -0,0 +1,22 @@ +namespace :after_party do + desc 'Deployment task: migrate_revisions' + task migrate_revisions: :environment do + puts "Running deploy task 'migrate_revisions'" + + procedures = Procedure.with_discarded.where(draft_revision_id: nil) + progress = ProgressReport.new(procedures.count) + + puts "Processing procedures" + procedures.find_each do |procedure| + RevisionsMigration.add_revisions(procedure) + progress.inc + end + progress.finish + + TmpDossiersMigrateRevisionsJob.perform_later([]) + + # Update task as completed. If you remove the line below, the task will + # run with every deploy (or every time you call after_party:run). + AfterParty::TaskRecord.create version: '20200625113026' + end +end diff --git a/lib/tasks/deployment/20200630154829_add_traitements_from_dossiers.rake b/lib/tasks/deployment/20200630154829_add_traitements_from_dossiers.rake new file mode 100644 index 000000000..9940c9843 --- /dev/null +++ b/lib/tasks/deployment/20200630154829_add_traitements_from_dossiers.rake @@ -0,0 +1,18 @@ +namespace :after_party do + desc 'Deployment task: add_traitements_from_dossiers' + task add_traitements_from_dossiers: :environment do + puts "Running deploy task 'add_traitements_from_dossiers'" + + dossiers_termines = Dossier.state_termine + progress = ProgressReport.new(dossiers_termines.count) + dossiers_termines.find_each do |dossier| + dossier.traitements.create!(state: dossier.state, motivation: dossier.motivation, processed_at: dossier.processed_at) + progress.inc + end + progress.finish + + # Update task as completed. If you remove the line below, the task will + # run with every deploy (or every time you call after_party:run). + AfterParty::TaskRecord.create version: '20200630154829' + end +end diff --git a/lib/tasks/deployment/20200708101123_add_default_skip_validation_to_piece_justificative.rake b/lib/tasks/deployment/20200708101123_add_default_skip_validation_to_piece_justificative.rake new file mode 100644 index 000000000..7bd74babb --- /dev/null +++ b/lib/tasks/deployment/20200708101123_add_default_skip_validation_to_piece_justificative.rake @@ -0,0 +1,18 @@ +namespace :after_party do + desc 'Deployment task: add_default_skip_validation_to_piece_justificative' + task add_default_skip_validation_to_piece_justificative: :environment do + puts "Running deploy task 'add_default_skip_validation_to_piece_justificative'" + + tdcs = TypeDeChamp.where(type_champ: TypeDeChamp.type_champs.fetch(:piece_justificative)) + progress = ProgressReport.new(tdcs.count) + tdcs.find_each do |tdc| + tdc.update(skip_pj_validation: true) + progress.inc + end + progress.finish + + # Update task as completed. If you remove the line below, the task will + # run with every deploy (or every time you call after_party:run). + AfterParty::TaskRecord.create version: '20200708101123' + end +end diff --git a/lib/tasks/deployment/20200728150458_fix_cloned_revisions.rake b/lib/tasks/deployment/20200728150458_fix_cloned_revisions.rake new file mode 100644 index 000000000..abfb8b23a --- /dev/null +++ b/lib/tasks/deployment/20200728150458_fix_cloned_revisions.rake @@ -0,0 +1,25 @@ +namespace :after_party do + desc 'Deployment task: fix_cloned_revisions' + task fix_cloned_revisions: :environment do + puts "Running deploy task 'fix_cloned_revisions'" + + Procedure.with_discarded.where(aasm_state: :brouillon).where.not(published_revision_id: nil).update_all(published_revision_id: nil) + + types_de_champ = TypeDeChamp.joins(:revision).where('types_de_champ.procedure_id != procedure_revisions.procedure_id') + progress = ProgressReport.new(types_de_champ.count) + + types_de_champ.find_each do |type_de_champ| + procedure = type_de_champ.procedure ? type_de_champ.procedure : Procedure.with_discarded.find(type_de_champ.procedure_id) + revision_id = procedure.published_revision_id || procedure.draft_revision_id + type_de_champ.update_column(:revision_id, revision_id) + progress.inc + end + + progress.finish + + # Update task as completed. If you remove the line below, the task will + # run with every deploy (or every time you call after_party:run). + AfterParty::TaskRecord + .create version: AfterParty::TaskRecorder.new(__FILE__).timestamp + end +end diff --git a/lib/tasks/deployment/20200813111957_fix_geo_areas_geometry.rake b/lib/tasks/deployment/20200813111957_fix_geo_areas_geometry.rake new file mode 100644 index 000000000..3969494b9 --- /dev/null +++ b/lib/tasks/deployment/20200813111957_fix_geo_areas_geometry.rake @@ -0,0 +1,71 @@ +namespace :after_party do + desc 'Deployment task: fix_geo_areas_geometry' + task fix_geo_areas_geometry: :environment do + puts "Running deploy task 'fix_geo_areas_geometry'" + + geometry_collections = GeoArea.where("geometry -> 'type' = '\"GeometryCollection\"'") + multi_polygons = GeoArea.where("geometry -> 'type' = '\"MultiPolygon\"'") + multi_line_strings = GeoArea.where("geometry -> 'type' = '\"MultiLineString\"'") + + def valid_geometry?(geometry) + RGeo::GeoJSON.decode(geometry.to_json, geo_factory: RGeo::Geographic.simple_mercator_factory) + true + rescue + false + end + + progress = ProgressReport.new(geometry_collections.count) + geometry_collections.find_each do |geometry_collection| + geometry_collection.geometry['geometries'].each do |geometry| + if valid_geometry?(geometry) + geometry_collection.champ.geo_areas.create!(geometry: geometry, source: 'selection_utilisateur') + end + end + + geometry_collection.destroy + progress.inc + end + progress.finish + + progress = ProgressReport.new(multi_line_strings.count) + multi_line_strings.find_each do |multi_line_string| + multi_line_string.geometry['coordinates'].each do |coordinates| + geometry = { + type: 'LineString', + coordinates: coordinates + } + + if valid_geometry?(geometry) + multi_line_string.champ.geo_areas.create!(geometry: geometry, source: 'selection_utilisateur') + end + end + + multi_line_string.destroy + progress.inc + end + progress.finish + + progress = ProgressReport.new(multi_polygons.count) + multi_polygons.find_each do |multi_polygon| + multi_polygon.geometry['coordinates'].each do |coordinates| + geometry = { + type: 'Polygon', + coordinates: coordinates + } + + if valid_geometry?(geometry) + multi_polygon.champ.geo_areas.create!(geometry: geometry, source: 'selection_utilisateur') + end + end + + multi_polygon.destroy + progress.inc + end + progress.finish + + # Update task as completed. If you remove the line below, the task will + # run with every deploy (or every time you call after_party:run). + AfterParty::TaskRecord + .create version: AfterParty::TaskRecorder.new(__FILE__).timestamp + end +end diff --git a/lib/tasks/deployment/20201001161931_migrate_filters_to_use_stable_id.rake b/lib/tasks/deployment/20201001161931_migrate_filters_to_use_stable_id.rake new file mode 100644 index 000000000..d4df6b6e6 --- /dev/null +++ b/lib/tasks/deployment/20201001161931_migrate_filters_to_use_stable_id.rake @@ -0,0 +1,50 @@ +namespace :after_party do + desc 'Deployment task: migrate_filters_to_use_stable_id' + task migrate_filters_to_use_stable_id: :environment do + puts "Running deploy task 'migrate_filters_to_use_stable_id'" + + procedure_presentations = ProcedurePresentation.where("filters -> 'migrated' IS NULL") + progress = ProgressReport.new(procedure_presentations.count) + procedure_presentations.find_each do |procedure_presentation| + filters = procedure_presentation.filters + sort = procedure_presentation.sort + displayed_fields = procedure_presentation.displayed_fields + + ['tous', 'suivis', 'traites', 'a-suivre', 'archives'].each do |statut| + filters[statut] = filters[statut].map do |filter| + table, column = filter.values_at('table', 'column') + if table && (table == 'type_de_champ' || table == 'type_de_champ_private') + type_de_champ = TypeDeChamp.find_by(id: column) + filter['column'] = type_de_champ&.stable_id&.to_s + end + filter + end + end + + table, column = sort.values_at('table', 'column') + if table && (table == 'type_de_champ' || table == 'type_de_champ_private') + type_de_champ = TypeDeChamp.find_by(id: column) + sort['column'] = type_de_champ&.stable_id&.to_s + end + + displayed_fields = displayed_fields.map do |displayed_field| + table, column = displayed_field.values_at('table', 'column') + if table && (table == 'type_de_champ' || table == 'type_de_champ_private') + type_de_champ = TypeDeChamp.find_by(id: column) + displayed_field['column'] = type_de_champ&.stable_id&.to_s + end + displayed_field + end + + filters['migrated'] = true + procedure_presentation.update_columns(filters: filters, sort: sort, displayed_fields: displayed_fields) + progress.inc + end + progress.finish + + # Update task as completed. If you remove the line below, the task will + # run with every deploy (or every time you call after_party:run). + AfterParty::TaskRecord + .create version: AfterParty::TaskRecorder.new(__FILE__).timestamp + end +end diff --git a/lib/tasks/deployment/20201006123842_setup_first_stats.rake b/lib/tasks/deployment/20201006123842_setup_first_stats.rake new file mode 100644 index 000000000..cfe4c93af --- /dev/null +++ b/lib/tasks/deployment/20201006123842_setup_first_stats.rake @@ -0,0 +1,11 @@ +namespace :after_party do + desc 'Deployment task: setup_first_stats' + task setup_first_stats: :environment do + Stat.update_stats + + # Update task as completed. If you remove the line below, the task will + # run with every deploy (or every time you call after_party:run). + AfterParty::TaskRecord + .create version: AfterParty::TaskRecorder.new(__FILE__).timestamp + end +end diff --git a/lib/tasks/deployment/20201218163035_fix_types_de_champ_revisions.rake b/lib/tasks/deployment/20201218163035_fix_types_de_champ_revisions.rake new file mode 100644 index 000000000..c4c118ce0 --- /dev/null +++ b/lib/tasks/deployment/20201218163035_fix_types_de_champ_revisions.rake @@ -0,0 +1,19 @@ +namespace :after_party do + desc 'Deployment task: fix_types_de_champ_revisions' + task fix_types_de_champ_revisions: :environment do + puts "Running deploy task 'fix_types_de_champ_revisions'" + + types_de_champ = TypeDeChamp.joins(:parent).where('types_de_champ.revision_id != parents_types_de_champ.revision_id') + progress = ProgressReport.new(types_de_champ.count) + types_de_champ.find_each do |type_de_champ| + type_de_champ.update_column(:revision_id, type_de_champ.parent.revision_id) + progress.inc + end + progress.finish + + # Update task as completed. If you remove the line below, the task will + # run with every deploy (or every time you call after_party:run). + AfterParty::TaskRecord + .create version: AfterParty::TaskRecorder.new(__FILE__).timestamp + end +end diff --git a/spec/lib/tasks/deployment/20200708101123_add_default_skip_validation_to_piece_justificative.rake_spec.rb b/spec/lib/tasks/deployment/20200708101123_add_default_skip_validation_to_piece_justificative.rake_spec.rb new file mode 100644 index 000000000..93ed3bdef --- /dev/null +++ b/spec/lib/tasks/deployment/20200708101123_add_default_skip_validation_to_piece_justificative.rake_spec.rb @@ -0,0 +1,25 @@ +describe '20200708101123_add_default_skip_validation_to_piece_justificative.rake' do + let(:rake_task) { Rake::Task['after_party:add_default_skip_validation_to_piece_justificative'] } + let!(:pj_type_de_champ) { create(:type_de_champ_piece_justificative) } + let!(:text_type_de_champ) { create(:type_de_champ_text) } + + before do + rake_task.invoke + text_type_de_champ.reload + pj_type_de_champ.reload + end + + after { rake_task.reenable } + + context 'on a piece_justificative type de champ' do + it 'sets the skip_pj_validation option' do + expect(pj_type_de_champ.skip_pj_validation).to be_truthy + end + end + + context 'on a non piece_justificative type de champ' do + it 'does not set the skip_pj_validation option' do + expect(text_type_de_champ.skip_pj_validation).to be_blank + end + end +end diff --git a/spec/lib/tasks/deployment/20201001161931_migrate_filters_to_use_stable_id_spec.rb b/spec/lib/tasks/deployment/20201001161931_migrate_filters_to_use_stable_id_spec.rb new file mode 100644 index 000000000..02c51be49 --- /dev/null +++ b/spec/lib/tasks/deployment/20201001161931_migrate_filters_to_use_stable_id_spec.rb @@ -0,0 +1,60 @@ +describe '20201001161931_migrate_filters_to_use_stable_id' do + let(:rake_task) { Rake::Task['after_party:migrate_filters_to_use_stable_id'] } + + let(:procedure) { create(:procedure, :with_instructeur, :with_type_de_champ) } + let(:type_de_champ) { procedure.types_de_champ.first } + let(:sort) do + { + "table" => "type_de_champ", + "column" => type_de_champ.id.to_s, + "order" => "asc" + } + end + let(:filters) do + { + 'tous' => [ + { + "label" => "test", + "table" => "type_de_champ", + "column" => type_de_champ.id.to_s, + "value" => "test" + } + ], + 'suivis' => [], + 'traites' => [], + 'a-suivre' => [], + 'archives' => [] + } + end + let(:displayed_fields) do + [ + { + "label" => "test", + "table" => "type_de_champ", + "column" => type_de_champ.id.to_s + } + ] + end + let!(:procedure_presentation) do + type_de_champ.update_column(:stable_id, 13) + procedure_presentation = create(:procedure_presentation, procedure: procedure, assign_to: procedure.groupe_instructeurs.first.assign_tos.first) + procedure_presentation.update_columns(sort: sort, filters: filters, displayed_fields: displayed_fields) + procedure_presentation + end + + before do + rake_task.invoke + procedure_presentation.reload + end + + after { rake_task.reenable } + + context "should migrate procedure_presentation" do + it "columns are updated" do + expect(procedure_presentation.sort['column']).to eq(type_de_champ.stable_id.to_s) + expect(procedure_presentation.filters['tous'][0]['column']).to eq(type_de_champ.stable_id.to_s) + expect(procedure_presentation.displayed_fields[0]['column']).to eq(type_de_champ.stable_id.to_s) + expect(procedure_presentation.filters['migrated']).to eq(true) + end + end +end From 6d5f44d489e652743d4596aba0b2c3bd3f3ee250 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Tue, 22 Feb 2022 17:17:55 +0100 Subject: [PATCH 14/39] config: translate the CSP comments from french to english --- .../initializers/content_security_policy.rb | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index c798a1bed..f0021b58b 100644 --- a/config/initializers/content_security_policy.rb +++ b/config/initializers/content_security_policy.rb @@ -5,22 +5,20 @@ # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy Rails.application.config.content_security_policy do |policy| - # Whitelist image images_whitelist = ["*.openstreetmap.org", "*.cloud.ovh.net", "*"] images_whitelist << URI(DS_PROXY_URL).host if DS_PROXY_URL.present? images_whitelist << URI(MATOMO_IFRAME_URL).host if MATOMO_IFRAME_URL.present? policy.img_src(:self, :data, :blob, *images_whitelist) - # Whitelist JS: nous, sendinblue et matomo - # miniprofiler et nous avons quelques boutons inline :( + # Javascript: allow us, SendInBlue and Matomo. + # We need unsafe_inline because miniprofiler and us have some inline buttons :( scripts_whitelist = ["*.sendinblue.com", "*.crisp.chat", "crisp.chat", "*.sibautomation.com", "sibautomation.com", "cdn.jsdelivr.net", "maxcdn.bootstrapcdn.com", "code.jquery.com"] scripts_whitelist << URI(MATOMO_IFRAME_URL).host if MATOMO_IFRAME_URL.present? policy.script_src(:self, :unsafe_eval, :unsafe_inline, :blob, *scripts_whitelist) - # Pour les CSS, on a beaucoup de style inline et quelques balises