feat(Procedure.for_tiers_enabled): allow super admin to disable for_tiers

This commit is contained in:
mfo 2024-04-18 11:28:49 +02:00
parent b40cc2a54e
commit 84c1a485e5
7 changed files with 65 additions and 29 deletions

View file

@ -46,6 +46,7 @@ class ProcedureDashboard < Administrate::BaseDashboard
max_duree_conservation_dossiers_dans_ds: Field::Number,
estimated_duration_visible: Field::Boolean,
piece_justificative_multiple: Field::Boolean,
for_tiers_enabled: Field::Boolean,
replaced_by_procedure_id: Field::String,
tags: Field::Text,
template: Field::Boolean
@ -109,6 +110,7 @@ class ProcedureDashboard < Administrate::BaseDashboard
:max_duree_conservation_dossiers_dans_ds,
:estimated_duration_visible,
:piece_justificative_multiple,
:for_tiers_enabled,
:replaced_by_procedure_id
].freeze
@ -121,6 +123,7 @@ class ProcedureDashboard < Administrate::BaseDashboard
:max_duree_conservation_dossiers_dans_ds,
:estimated_duration_visible,
:piece_justificative_multiple,
:for_tiers_enabled,
:replaced_by_procedure_id
].freeze

View file

@ -3,6 +3,7 @@
= render partial: "shared/dossiers/submit_is_over", locals: { dossier: @dossier }
- if !dossier_submission_is_closed?(@dossier)
- if @dossier.procedure.for_tiers_enabled?
= form_for @dossier, url: identite_dossier_path(@dossier), method: :patch, html: { class: "form" }, data: {turbo: true, controller: :autosubmit} do |f|
%fieldset#radio-rich-hint.fr-fieldset{ "aria-labelledby" => "radio-rich-hint-legend radio-rich-hint-messages" }

View file

@ -37,6 +37,7 @@ en:
lien_dpo: Link or email to contact the data protection officer (DPO)
duree_conservation_dossiers_dans_ds: Duration files will be kept
max_duree_conservation_dossiers_dans_ds: Max duration allowed to keep files
for_tiers_enabled: Enable a third party to submit a file
aasm_state:
brouillon: Draft
publiee: Published

View file

@ -20,6 +20,7 @@ fr:
organisation: Organisme
duree_conservation_dossiers_dans_ds: Durée de conservation des dossiers
max_duree_conservation_dossiers_dans_ds: Durée maximale de conservation des dossiers (autorisée par un super admin)
for_tiers_enabled: Activer le dépot par un tiers
id: Id
libelle: Titre de la démarche
description: Quel est lobjet de la démarche ?

View file

@ -0,0 +1,5 @@
class AddColumnForTiersEnabledToProcedure < ActiveRecord::Migration[7.0]
def change
add_column :procedures, :for_tiers_enabled, :boolean, default: true, null: false
end
end

View file

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.0].define(version: 2024_04_16_062900) do
ActiveRecord::Schema[7.0].define(version: 2024_04_17_053843) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_buffercache"
enable_extension "pg_stat_statements"
@ -894,6 +894,7 @@ ActiveRecord::Schema[7.0].define(version: 2024_04_16_062900) do
t.boolean "euro_flag", default: false
t.boolean "experts_require_administrateur_invitation", default: false
t.boolean "for_individual", default: false
t.boolean "for_tiers_enabled", default: true, null: false
t.datetime "hidden_at", precision: nil
t.datetime "hidden_at_as_template", precision: nil
t.boolean "instructeurs_self_management_enabled", default: false

View file

@ -1,5 +1,4 @@
describe 'users/dossiers/identite', type: :view do
let(:procedure) { create(:simple_procedure, :for_individual) }
let(:dossier) { create(:dossier, :with_service, state: Dossier.states.fetch(:brouillon), procedure: procedure) }
before do
@ -9,6 +8,14 @@ describe 'users/dossiers/identite', type: :view do
subject! { render }
context 'when procedure has for_tiers_enabled' do
let(:procedure) { create(:simple_procedure, :for_individual) }
it 'has choice for you or a tiers' do
expect(rendered).to have_content "Pour vous"
expect(rendered).to have_content "Pour un bénéficiaire : membre de la famille, proche, mandant, professionnel en charge du suivi du dossier…"
end
it 'has identity fields' do
within('.individual-infos') do
expect(rendered).to have_field(id: 'Prenom')
@ -24,3 +31,20 @@ describe 'users/dossiers/identite', type: :view do
end
end
end
context 'when procedure has for_tiers_enabled' do
let(:procedure) { create(:simple_procedure, :for_individual, for_tiers_enabled: false) }
it 'has choice for you or a tiers' do
expect(rendered).not_to have_content "Pour vous"
expect(rendered).not_to have_content "Pour un bénéficiaire : membre de la famille, proche, mandant, professionnel en charge du suivi du dossier…"
end
it 'has identity fields' do
within('.individual-infos') do
expect(rendered).to have_field(id: 'Prenom')
expect(rendered).to have_field(id: 'Nom')
end
end
end
end