Merge pull request #7255 from betagouv/main

2022-05-05-01
This commit is contained in:
mfo 2022-05-05 14:01:31 +02:00 committed by GitHub
commit 5e6fcdfee1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 120 additions and 52 deletions

View file

@ -103,10 +103,10 @@ module Administrateurs
elsif @procedure.brouillon?
reset_procedure
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
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
@ -254,7 +254,26 @@ module Administrateurs
end
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?
params.require(:procedure).permit(*editable_params)
else

View file

@ -30,7 +30,7 @@ module Instructeurs
private
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"
return redirect_to instructeur_procedure_path(procedure)
end

View file

@ -174,7 +174,7 @@ module Users
respond_to do |format|
format.html { render :brouillon }
format.js { render :brouillon }
format.js
end
end

View file

@ -34,7 +34,7 @@
# monavis_embed :text
# organisation :string
# path :string not null
# procedure_expires_when_termine_enabled :boolean default(FALSE)
# procedure_expires_when_termine_enabled :boolean default(TRUE)
# published_at :datetime
# routing_criteria_name :text default("Votre ville")
# 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])
= 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
%h2.procedure-admin-explanation Indispensable avant publication
.procedure-grid

View file

@ -20,43 +20,41 @@
Nous vous invitons à regarder
= link_to 'la documentation', ARCHIVAGE_DOC_URL
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
%thead
%tr
%th  
%th.text-right Nombre de dossiers terminés
%th.text-right Poids estimé
%th.center Télécharger
%tbody
- @count_dossiers_termines_by_month.each do |count_by_month|
- month = count_by_month["month"].to_date
- nb_dossiers_termines = count_by_month["count"]
- matching_archive = @archives.find { |archive| archive.time_span_type == 'monthly' && archive.month == month }
- weight = estimate_weight(matching_archive, nb_dossiers_termines, @average_dossier_weight)
%table.table.hoverable.archive-table
%thead
%tr
%th  
%th.text-right Nombre de dossiers terminés
%th.text-right Poids estimé
%th.center Télécharger
%tr
%td
= I18n.l(month, format: "%B %Y").capitalize
%td.text-right
= nb_dossiers_termines
%td.text-right
= number_to_human_size(weight)
%td.center
- if matching_archive.present?
- if matching_archive.status == 'generated' && matching_archive.file.attached?
= link_to url_for(matching_archive.file), class: 'button primary' do
%span.icon.download-white
= t(:archive_ready_html, scope: [:instructeurs, :procedure], generated_period: time_ago_in_words(matching_archive.updated_at))
- else
%span.icon.retry
= t(:archive_pending_html, scope: [:instructeurs, :procedure], created_period: time_ago_in_words(matching_archive.created_at))
- elsif weight < Archive::MAX_SIZE
= link_to instructeur_archives_path(@procedure, type:'monthly', month: month.strftime('%Y-%m')), method: :post, class: "button" do
%span.icon.new-folder
Demander la création
%tbody
- @count_dossiers_termines_by_month.each do |count_by_month|
- month = count_by_month["month"].to_date
- nb_dossiers_termines = count_by_month["count"]
- matching_archive = @archives.find { |archive| archive.time_span_type == 'monthly' && archive.month == month }
- weight = estimate_weight(matching_archive, nb_dossiers_termines, @average_dossier_weight)
%tr
%td
= I18n.l(month, format: "%B %Y").capitalize
%td.text-right
= nb_dossiers_termines
%td.text-right
= number_to_human_size(weight)
%td.center
- if matching_archive.present?
- if matching_archive.status == 'generated' && matching_archive.file.attached?
= link_to url_for(matching_archive.file), class: 'button primary' do
%span.icon.download-white
= t(:archive_ready_html, scope: [:instructeurs, :procedure], generated_period: time_ago_in_words(matching_archive.updated_at))
- else
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
%span.icon.retry
= t(:archive_pending_html, scope: [:instructeurs, :procedure], created_period: time_ago_in_words(matching_archive.created_at))
- elsif weight < Archive::MAX_SIZE
= link_to instructeur_archives_path(@procedure, type:'monthly', month: month.strftime('%Y-%m')), method: :post, class: "button" do
%span.icon.new-folder
Demander la création
- else
Archive trop volumineuse

View file

@ -131,3 +131,5 @@ SENDINBLUE_BALANCING_VALUE="50"
# When present, N % of emails will be sent using DoList
# (and the others using the default SMTP provider)
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("/")
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_PROCEDURE_EXPIRES_URL = [DOC_URL, "expiration-et-suppression-des-dossiers"].join("/")
FAQ_URL = ENV.fetch("FAQ_URL", "https://faq.demarches-simplifiees.fr")
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.
ActiveRecord::Schema.define(version: 2022_04_26_140107) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
enable_extension "unaccent"
@ -651,7 +650,7 @@ ActiveRecord::Schema.define(version: 2022_04_26_140107) do
t.string "organisation"
t.bigint "parent_procedure_id"
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.bigint "published_revision_id"
t.text "routing_criteria_name", default: "Votre ville"

View file

@ -215,7 +215,7 @@ describe Administrateurs::ProceduresController, type: :controller do
end
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
before do
@ -229,7 +229,7 @@ describe Administrateurs::ProceduresController, type: :controller do
context 'when administrateur is connected' do
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
end
@ -239,6 +239,7 @@ describe Administrateurs::ProceduresController, type: :controller do
let(:organisation) { 'plop' }
let(:direction) { 'plap' }
let(:duree_conservation_dossiers_dans_ds) { 7 }
let(:procedure_expires_when_termine_enabled) { true }
before { update_procedure }
@ -250,9 +251,10 @@ describe Administrateurs::ProceduresController, type: :controller do
it { expect(subject.organisation).to eq(organisation) }
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.procedure_expires_when_termine_enabled).to eq(true) }
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 }
end

View file

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

View file

@ -38,7 +38,7 @@ describe 'Administrateurs can edit procedures', js: true do
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
@ -55,7 +55,7 @@ describe 'Administrateurs can edit procedures', js: true do
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

View file

@ -57,4 +57,24 @@ describe 'administrateurs/procedures/show.html.haml', type: :view do
it { expect(rendered).to have_content('Réactiver') }
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

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
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
expect(rendered).to have_text("La démarche liée à votre dossier est supprimée")