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,27 +3,28 @@
= render partial: "shared/dossiers/submit_is_over", locals: { dossier: @dossier }
- if !dossier_submission_is_closed?(@dossier)
= form_for @dossier, url: identite_dossier_path(@dossier), method: :patch, html: { class: "form" }, data: {turbo: true, controller: :autosubmit} do |f|
- 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" }
%legend#radio-rich-hint-legend.fr-fieldset__legend--regular.fr-fieldset__legend
= t('views.users.dossiers.identite.legend')
%fieldset#radio-rich-hint.fr-fieldset{ "aria-labelledby" => "radio-rich-hint-legend radio-rich-hint-messages" }
%legend#radio-rich-hint-legend.fr-fieldset__legend--regular.fr-fieldset__legend
= t('views.users.dossiers.identite.legend')
.fr-fieldset__element
.fr-radio-group.fr-radio-rich
= f.radio_button :for_tiers, false, required: true, id: "radio-self-manage"
%label.fr-label{ for: "radio-self-manage" }
= t('activerecord.attributes.dossier.for_tiers.false')
.fr-radio-rich__img
%span.fr-icon-user-fill
.fr-fieldset__element
.fr-radio-group.fr-radio-rich
= f.radio_button :for_tiers, true, required: true, id: "radio-tiers-manage"
%label.fr-label{ for: "radio-tiers-manage" }
= t('activerecord.attributes.dossier.for_tiers.true')
.fr-radio-rich__img
%span.fr-icon-parent-fill
.fr-fieldset__element
.fr-radio-group.fr-radio-rich
= f.radio_button :for_tiers, false, required: true, id: "radio-self-manage"
%label.fr-label{ for: "radio-self-manage" }
= t('activerecord.attributes.dossier.for_tiers.false')
.fr-radio-rich__img
%span.fr-icon-user-fill
.fr-fieldset__element
.fr-radio-group.fr-radio-rich
= f.radio_button :for_tiers, true, required: true, id: "radio-tiers-manage"
%label.fr-label{ for: "radio-tiers-manage" }
= t('activerecord.attributes.dossier.for_tiers.true')
.fr-radio-rich__img
%span.fr-icon-parent-fill
= f.submit t('views.users.dossiers.identite.continue'), class: 'visually-hidden'
= f.submit t('views.users.dossiers.identite.continue'), class: 'visually-hidden'
= render Dossiers::IndividualFormComponent.new(dossier: @dossier)

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,18 +8,43 @@ describe 'users/dossiers/identite', type: :view do
subject! { render }
it 'has identity fields' do
within('.individual-infos') do
expect(rendered).to have_field(id: 'Prenom')
expect(rendered).to have_field(id: 'Nom')
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')
expect(rendered).to have_field(id: 'Nom')
end
end
context 'when the demarche asks for the birthdate' do
let(:procedure) { create(:simple_procedure, for_individual: true, ask_birthday: true) }
it 'has a birthday field' do
expect(rendered).to have_field('Date de naissance')
end
end
end
context 'when the demarche asks for the birthdate' do
let(:procedure) { create(:simple_procedure, for_individual: true, ask_birthday: true) }
context 'when procedure has for_tiers_enabled' do
let(:procedure) { create(:simple_procedure, :for_individual, for_tiers_enabled: false) }
it 'has a birthday field' do
expect(rendered).to have_field('Date de naissance')
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