feat(procedure.procedure_expires_when_termine_enabled): enable by default, allow contributor to choose the default settings of this flag using an env var during migration. ie: DEFAULT_PROCEDURE_EXPIRES_WHEN_TERMINE_ENABLED=true|false

feat(administrateurs/procedures#show): warning/alert when procedure_expires_when_termine_enabled is not true on current procedure

feat(administrateur/procedure#update): after an update redirect to procedure show: suggested by: https://ux.stackexchange.com/questions/55291/after-updating-form-should-redirect-back-to-form-itself-or-to-the-show-page-or-b and confirmed by Olivier

clean(Flipper.archive_zip_globale): no more in use, so remove all occurences

Update app/views/administrateurs/procedures/_suggest_expires_when_termine.html.haml

Co-authored-by: Pierre de La Morinerie <kemenaran@gmail.com>

Update app/views/administrateurs/procedures/_suggest_expires_when_termine.html.haml

Co-authored-by: Pierre de La Morinerie <kemenaran@gmail.com>

Update app/views/administrateurs/procedures/_suggest_expires_when_termine.html.haml

Co-authored-by: Pierre de La Morinerie <kemenaran@gmail.com>

Update spec/views/administrateurs/procedures/show.html.haml_spec.rb

Co-authored-by: Pierre de La Morinerie <kemenaran@gmail.com>

fix(review): typo, why ena?, who knows

fix(env.example.optional): add missing DEFAULT_PROCEDURE_EXPIRES_WHEN_TERMINE_ENABLED
This commit is contained in:
Martin 2022-02-22 16:09:00 +01:00
parent 72fad93c61
commit 3737311390
15 changed files with 119 additions and 51 deletions

View file

@ -103,10 +103,10 @@ module Administrateurs
elsif @procedure.brouillon? elsif @procedure.brouillon?
reset_procedure reset_procedure
flash.notice = 'Démarche modifiée. Tous les dossiers de cette démarche ont été supprimés.' flash.notice = 'Démarche modifiée. Tous les dossiers de cette démarche ont été supprimés.'
redirect_to edit_admin_procedure_path(id: @procedure.id) redirect_to admin_procedure_path(id: @procedure.id)
else else
flash.notice = 'Démarche modifiée.' flash.notice = 'Démarche modifiée.'
redirect_to edit_admin_procedure_path(id: @procedure.id) redirect_to admin_procedure_path(id: @procedure.id)
end end
end end
@ -254,7 +254,26 @@ module Administrateurs
end end
def procedure_params def procedure_params
editable_params = [:libelle, :description, :organisation, :direction, :lien_site_web, :cadre_juridique, :deliberation, :notice, :web_hook_url, :declarative_with_state, :logo, :auto_archive_on, :monavis_embed, :api_entreprise_token, :duree_conservation_dossiers_dans_ds, :zone_id, :lien_dpo] editable_params = [
:libelle,
:description,
:organisation,
:direction,
:lien_site_web,
:cadre_juridique,
:deliberation,
:notice,
:web_hook_url,
:declarative_with_state,
:logo,
:auto_archive_on,
:monavis_embed,
:api_entreprise_token,
:duree_conservation_dossiers_dans_ds,
:zone_id,
:lien_dpo,
:procedure_expires_when_termine_enabled
]
permited_params = if @procedure&.locked? permited_params = if @procedure&.locked?
params.require(:procedure).permit(*editable_params) params.require(:procedure).permit(*editable_params)
else else

View file

@ -30,7 +30,7 @@ module Instructeurs
private private
def ensure_procedure_enabled def ensure_procedure_enabled
if !procedure.feature_enabled?(:archive_zip_globale) || procedure.brouillon? if procedure.brouillon?
flash[:alert] = "L'accès aux archives nest pas disponible pour cette démarche, merci den faire la demande à l'équipe de démarches simplifiees" flash[:alert] = "L'accès aux archives nest pas disponible pour cette démarche, merci den faire la demande à l'équipe de démarches simplifiees"
return redirect_to instructeur_procedure_path(procedure) return redirect_to instructeur_procedure_path(procedure)
end end

View file

@ -34,7 +34,7 @@
# monavis_embed :text # monavis_embed :text
# organisation :string # organisation :string
# path :string not null # path :string not null
# procedure_expires_when_termine_enabled :boolean default(FALSE) # procedure_expires_when_termine_enabled :boolean default(TRUE)
# published_at :datetime # published_at :datetime
# routing_criteria_name :text default("Votre ville") # routing_criteria_name :text default("Votre ville")
# routing_enabled :boolean # routing_enabled :boolean

View file

@ -0,0 +1,10 @@
.container{ :"data-test-suggest_expires_when_termine" => "true" }
.card.warning
.card-title
Veuillez activer la suppression automatique des dossiers expirés.
%p
Pour des raisons liées au RGPD, veuillez activer la suppression automatique des dossiers expirés (#{procedure.duree_conservation_dossiers_dans_ds} mois après que le dossier ait été traité). Vous pouvez à tout moment récupérer une archive de la démarche en vous connectant en tant quinstructeur.
= link_to "En savoir plus", DOC_PROCEDURE_EXPIRES_URL, rel: 'noopener', target: '_blank', class: ''
%p
= button_to "Activer lexpiration des données", admin_procedure_path(id: procedure.id, params: { procedure: { procedure_expires_when_termine_enabled: true }}), method: :patch, class: 'button primary', form: { data: { turbo: true } }

View file

@ -43,6 +43,8 @@
= t(:has_changes, scope: [:administrateurs, :revision_changes]) = t(:has_changes, scope: [:administrateurs, :revision_changes])
= render partial: 'revision_changes', locals: { changes: @procedure.revision_changes } = render partial: 'revision_changes', locals: { changes: @procedure.revision_changes }
- if !@procedure.procedure_expires_when_termine_enabled?
= render partial: 'administrateurs/procedures/suggest_expires_when_termine', locals: { procedure: @procedure }
.container .container
%h2.procedure-admin-explanation Indispensable avant publication %h2.procedure-admin-explanation Indispensable avant publication
.procedure-grid .procedure-grid

View file

@ -20,7 +20,7 @@
Nous vous invitons à regarder Nous vous invitons à regarder
= link_to 'la documentation', ARCHIVAGE_DOC_URL = link_to 'la documentation', ARCHIVAGE_DOC_URL
afin de voir les options à votre disposition pour mettre en place un système darchive. afin de voir les options à votre disposition pour mettre en place un système darchive.
- if @procedure.feature_enabled?(:archive_zip_globale)
%table.table.hoverable.archive-table %table.table.hoverable.archive-table
%thead %thead
%tr %tr
@ -58,5 +58,3 @@
Demander la création Demander la création
- else - else
Archive trop volumineuse Archive trop volumineuse
- else
%p Cet fonctionnalité est en cours de deploiement, merci de faire une demande à notre support pour que nous l'activions pour votre démarche

View file

@ -131,3 +131,5 @@ SENDINBLUE_BALANCING_VALUE="50"
# When present, N % of emails will be sent using DoList # When present, N % of emails will be sent using DoList
# (and the others using the default SMTP provider) # (and the others using the default SMTP provider)
DOLIST_BALANCING_VALUE="50" DOLIST_BALANCING_VALUE="50"
# Used only by a migration to choose your default regarding procedure archive dossiers after duree_conservation_dossiers_dans_ds
# DEFAULT_PROCEDURE_EXPIRES_WHEN_TERMINE_ENABLED=true

View file

@ -33,6 +33,7 @@ API_DOC_URL = [DOC_URL, "pour-aller-plus-loin", "graphql"].join("/")
WEBHOOK_DOC_URL = [DOC_URL, "pour-aller-plus-loin", "webhook"].join("/") WEBHOOK_DOC_URL = [DOC_URL, "pour-aller-plus-loin", "webhook"].join("/")
ARCHIVAGE_DOC_URL = [DOC_URL, "pour-aller-plus-loin", "archivage-longue-duree-des-demarches"].join("/") ARCHIVAGE_DOC_URL = [DOC_URL, "pour-aller-plus-loin", "archivage-longue-duree-des-demarches"].join("/")
DOC_INTEGRATION_MONAVIS_URL = [DOC_URL, "tutoriels", "integration-du-bouton-mon-avis"].join("/") DOC_INTEGRATION_MONAVIS_URL = [DOC_URL, "tutoriels", "integration-du-bouton-mon-avis"].join("/")
DOC_PROCEDURE_EXPIRES_URL = [DOC_URL, "expiration-et-suppression-des-dossiers"].join("/")
FAQ_URL = ENV.fetch("FAQ_URL", "https://faq.demarches-simplifiees.fr") FAQ_URL = ENV.fetch("FAQ_URL", "https://faq.demarches-simplifiees.fr")
FAQ_ADMIN_URL = [FAQ_URL, "collection", "1-administrateur-creation-dun-formulaire"].join("/") FAQ_ADMIN_URL = [FAQ_URL, "collection", "1-administrateur-creation-dun-formulaire"].join("/")

View file

@ -0,0 +1,16 @@
# usage DEFAULT_PROCEDURE_EXPIRES_WHEN_TERMINE_ENABLED=true|false rails db:migrate:up VERSION=20220222150340
class SetDefaultProcedureExpiresWhenTermineEnabledToTrue < ActiveRecord::Migration[6.1]
def up
change_column :procedures,
:procedure_expires_when_termine_enabled,
:boolean,
default: ENV.fetch('DEFAULT_PROCEDURE_EXPIRES_WHEN_TERMINE_ENABLED') { true }
end
def down
change_column :procedures,
:procedure_expires_when_termine_enabled,
:boolean,
default: false
end
end

View file

@ -11,7 +11,6 @@
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2022_04_26_140107) do ActiveRecord::Schema.define(version: 2022_04_26_140107) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
enable_extension "unaccent" enable_extension "unaccent"
@ -651,7 +650,7 @@ ActiveRecord::Schema.define(version: 2022_04_26_140107) do
t.string "organisation" t.string "organisation"
t.bigint "parent_procedure_id" t.bigint "parent_procedure_id"
t.string "path", null: false t.string "path", null: false
t.boolean "procedure_expires_when_termine_enabled", default: false t.boolean "procedure_expires_when_termine_enabled", default: true
t.datetime "published_at" t.datetime "published_at"
t.bigint "published_revision_id" t.bigint "published_revision_id"
t.text "routing_criteria_name", default: "Votre ville" t.text "routing_criteria_name", default: "Votre ville"

View file

@ -215,7 +215,7 @@ describe Administrateurs::ProceduresController, type: :controller do
end end
describe 'PUT #update' do describe 'PUT #update' do
let!(:procedure) { create(:procedure, :with_type_de_champ, administrateur: admin) } let!(:procedure) { create(:procedure, :with_type_de_champ, administrateur: admin, procedure_expires_when_termine_enabled: false) }
context 'when administrateur is not connected' do context 'when administrateur is not connected' do
before do before do
@ -229,7 +229,7 @@ describe Administrateurs::ProceduresController, type: :controller do
context 'when administrateur is connected' do context 'when administrateur is connected' do
def update_procedure def update_procedure
put :update, params: { id: procedure.id, procedure: procedure_params } put :update, params: { id: procedure.id, procedure: procedure_params.merge(procedure_expires_when_termine_enabled: true) }
procedure.reload procedure.reload
end end
@ -239,6 +239,7 @@ describe Administrateurs::ProceduresController, type: :controller do
let(:organisation) { 'plop' } let(:organisation) { 'plop' }
let(:direction) { 'plap' } let(:direction) { 'plap' }
let(:duree_conservation_dossiers_dans_ds) { 7 } let(:duree_conservation_dossiers_dans_ds) { 7 }
let(:procedure_expires_when_termine_enabled) { true }
before { update_procedure } before { update_procedure }
@ -250,9 +251,10 @@ describe Administrateurs::ProceduresController, type: :controller do
it { expect(subject.organisation).to eq(organisation) } it { expect(subject.organisation).to eq(organisation) }
it { expect(subject.direction).to eq(direction) } it { expect(subject.direction).to eq(direction) }
it { expect(subject.duree_conservation_dossiers_dans_ds).to eq(duree_conservation_dossiers_dans_ds) } it { expect(subject.duree_conservation_dossiers_dans_ds).to eq(duree_conservation_dossiers_dans_ds) }
it { expect(subject.procedure_expires_when_termine_enabled).to eq(true) }
end end
it { is_expected.to redirect_to(edit_admin_procedure_path id: procedure.id) } it { is_expected.to redirect_to(admin_procedure_path id: procedure.id) }
it { expect(flash[:notice]).to be_present } it { expect(flash[:notice]).to be_present }
end end

View file

@ -9,7 +9,6 @@ describe Instructeurs::ArchivesController, type: :controller do
before do before do
sign_in(instructeur.user) sign_in(instructeur.user)
Flipper.enable(:archive_zip_globale, procedure1)
end end
after { Timecop.return } after { Timecop.return }

View file

@ -38,7 +38,7 @@ describe 'Administrateurs can edit procedures', js: true do
click_on 'Enregistrer' click_on 'Enregistrer'
expect(page).to have_field('procedure_libelle', with: 'Ma petite démarche') expect(page).to have_selector('.breadcrumbs li', text: 'Ma petite démarche')
end end
end end
@ -55,7 +55,7 @@ describe 'Administrateurs can edit procedures', js: true do
click_on 'Enregistrer' click_on 'Enregistrer'
expect(page).to have_field('procedure_libelle', with: 'Ma petite démarche') expect(page).to have_selector('.breadcrumbs li', text: 'Ma petite démarche')
end end
end end

View file

@ -57,4 +57,24 @@ describe 'administrateurs/procedures/show.html.haml', type: :view do
it { expect(rendered).to have_content('Réactiver') } it { expect(rendered).to have_content('Réactiver') }
end end
end end
describe 'procedure with expiration disabled' do
let(:procedure) { create(:procedure, procedure_expires_when_termine_enabled: true) }
before do
render
end
it 'does not render partial to enable procedure_expires_when_termine_enabled' do
expect(rendered).not_to have_css("div[data-test-suggest_expires_when_termine]")
end
end
describe 'procedure with expiration enabled' do
let(:procedure) { create(:procedure, procedure_expires_when_termine_enabled: false) }
before do
render
end
it 'renders a partial to enable procedure_expires_when_termine_enabled' do
expect(rendered).to have_css("div[data-test-suggest_expires_when_termine]")
end
end
end end

View file

@ -47,7 +47,7 @@ describe 'users/dossiers/show/header.html.haml', type: :view do
context "when the procedure is discarded with a dossier terminé" do context "when the procedure is discarded with a dossier terminé" do
let(:procedure) { create(:procedure, :discarded) } let(:procedure) { create(:procedure, :discarded) }
let(:dossier) { create(:dossier, state: "accepte", procedure: procedure) } let(:dossier) { create(:dossier, :accepte, procedure: procedure) }
it 'affiche que la démarche est supprimée' do it 'affiche que la démarche est supprimée' do
expect(rendered).to have_text("La démarche liée à votre dossier est supprimée") expect(rendered).to have_text("La démarche liée à votre dossier est supprimée")