Merge pull request #8805 from demarches-simplifiees/feat/8734
ETQ administrateur, je souhaite pouvoir bloquer l'accès aux experts à la messagerie
This commit is contained in:
commit
c498fa696f
9 changed files with 128 additions and 63 deletions
|
@ -3,7 +3,7 @@ module Administrateurs
|
|||
layout 'all', only: [:all, :administrateurs]
|
||||
respond_to :html, :xlsx
|
||||
|
||||
before_action :retrieve_procedure, only: [:champs, :annotations, :modifications, :edit, :zones, :monavis, :update_monavis, :jeton, :update_jeton, :publication, :publish, :transfert, :close, :allow_expert_review, :experts_require_administrateur_invitation, :reset_draft]
|
||||
before_action :retrieve_procedure, only: [:champs, :annotations, :modifications, :edit, :zones, :monavis, :update_monavis, :jeton, :update_jeton, :publication, :publish, :transfert, :close, :allow_expert_review, :allow_expert_messaging, :experts_require_administrateur_invitation, :reset_draft]
|
||||
before_action :draft_valid?, only: [:apercu]
|
||||
after_action :reset_procedure, only: [:update]
|
||||
|
||||
|
@ -324,6 +324,12 @@ module Administrateurs
|
|||
redirect_to admin_procedure_experts_path(@procedure)
|
||||
end
|
||||
|
||||
def allow_expert_messaging
|
||||
@procedure.update!(allow_expert_messaging: !@procedure.allow_expert_messaging)
|
||||
flash.notice = @procedure.allow_expert_messaging ? "Les experts ont accès à la messagerie" : "Les experts n'ont plus accès à la messagerie"
|
||||
redirect_to admin_procedure_experts_path(@procedure)
|
||||
end
|
||||
|
||||
def transfer
|
||||
admin = Administrateur.by_email(params[:email_admin].downcase)
|
||||
if admin.nil?
|
||||
|
|
|
@ -7,6 +7,7 @@ module Experts
|
|||
before_action :check_if_avis_revoked, except: [:index, :procedure]
|
||||
before_action :redirect_if_no_sign_up_needed, only: [:sign_up, :update_expert]
|
||||
before_action :set_avis_and_dossier, only: [:show, :instruction, :avis_list, :avis_new, :messagerie, :create_commentaire, :delete_commentaire, :update, :telecharger_pjs]
|
||||
before_action :check_messaging_allowed, only: [:messagerie, :create_commentaire]
|
||||
|
||||
A_DONNER_STATUS = 'a-donner'
|
||||
DONNES_STATUS = 'donnes'
|
||||
|
@ -155,6 +156,13 @@ module Experts
|
|||
|
||||
private
|
||||
|
||||
def check_messaging_allowed
|
||||
if !@avis.procedure.allow_expert_messaging
|
||||
flash[:alert] = "Vous n'êtes pas autorisé à acceder à la messagerie"
|
||||
redirect_to expert_avis_url(avis.procedure, avis)
|
||||
end
|
||||
end
|
||||
|
||||
def redirect_if_no_sign_up_needed
|
||||
avis = Avis.find(params[:id])
|
||||
|
||||
|
|
|
@ -4,13 +4,13 @@
|
|||
['Liste des experts']] }
|
||||
|
||||
.container
|
||||
%h1.page-title.mt-2 Experts invités sur #{@procedure.libelle}
|
||||
%h1.page-title.mt-2= t('.titles.main', libelle: @procedure.libelle)
|
||||
|
||||
.container.groupe-instructeur
|
||||
|
||||
.card
|
||||
.card-title Autoriser les instructeurs à solliciter des experts invités
|
||||
%p.notice Si cette fonctionnalité est désactivée, les instructeurs ne pourront plus solliciter d’experts
|
||||
.card-title= t('.titles.allow_invite_experts')
|
||||
%p.notice= t('.descriptions.allow_invite_experts')
|
||||
= form_for @procedure,
|
||||
method: :put,
|
||||
url: allow_expert_review_admin_procedure_path(@procedure),
|
||||
|
@ -23,8 +23,8 @@
|
|||
|
||||
- if @procedure.allow_expert_review?
|
||||
.card
|
||||
.card-title Gérer les experts invités de la démarche
|
||||
%p.notice Si cette fonctionnalité est activée, les instructeurs pourront uniquement inviter les experts de votre liste
|
||||
.card-title= t('.titles.manage_procedure_experts')
|
||||
%p.notice= t('.descriptions.manage_procedure_experts')
|
||||
= form_for @procedure,
|
||||
method: :put,
|
||||
url: experts_require_administrateur_invitation_admin_procedure_path(@procedure),
|
||||
|
@ -35,62 +35,75 @@
|
|||
%span.toggle-switch-label.on
|
||||
%span.toggle-switch-label.off
|
||||
|
||||
- if @procedure.experts_require_administrateur_invitation?
|
||||
.card
|
||||
.card-title Affecter des experts à la démarche
|
||||
= form_for :experts_procedure,
|
||||
url: admin_procedure_experts_path(@procedure),
|
||||
html: { class: 'form' } do |f|
|
||||
.card
|
||||
.card-title= t('.titles.allow_expert_messaging')
|
||||
%p.notice= t('.descriptions.allow_expert_messaging')
|
||||
= form_for @procedure,
|
||||
method: :put,
|
||||
url: allow_expert_messaging_admin_procedure_path(@procedure),
|
||||
html: { class: 'form procedure-form__column--form no-background' } do |f|
|
||||
%label.toggle-switch{ data: { controller: 'autosubmit' } }
|
||||
= f.check_box :allow_expert_messaging, class: 'toggle-switch-checkbox'
|
||||
%span.toggle-switch-control.round
|
||||
%span.toggle-switch-label.on
|
||||
%span.toggle-switch-label.off
|
||||
|
||||
.instructeur-wrapper
|
||||
%p.notice Pendant l'instruction d’un dossier, les instructeurs peuvent demander leur avis à un ou plusieurs experts.
|
||||
%p#experts-emails.notice Entrez les adresses email des experts que vous souhaitez affecter à cette démarche
|
||||
= hidden_field_tag :emails, nil
|
||||
= react_component("ComboMultiple",
|
||||
options: [],
|
||||
selected: [], disabled: [],
|
||||
group: '.instructeur-wrapper',
|
||||
name: 'emails',
|
||||
label: 'Emails',
|
||||
describedby: 'experts-emails',
|
||||
acceptNewValues: true)
|
||||
- if @procedure.experts_require_administrateur_invitation?
|
||||
.card
|
||||
.card-title Affecter des experts à la démarche
|
||||
= form_for :experts_procedure,
|
||||
url: admin_procedure_experts_path(@procedure),
|
||||
html: { class: 'form' } do |f|
|
||||
|
||||
= f.submit 'Affecter à la démarche', class: 'button primary send'
|
||||
- if @experts_procedure.present?
|
||||
%table.table.mt-2
|
||||
%thead
|
||||
.instructeur-wrapper
|
||||
%p.notice Pendant l'instruction d’un dossier, les instructeurs peuvent demander leur avis à un ou plusieurs experts.
|
||||
%p#experts-emails.notice Entrez les adresses email des experts que vous souhaitez affecter à cette démarche
|
||||
= hidden_field_tag :emails, nil
|
||||
= react_component("ComboMultiple",
|
||||
options: [],
|
||||
selected: [], disabled: [],
|
||||
group: '.instructeur-wrapper',
|
||||
name: 'emails',
|
||||
label: 'Emails',
|
||||
describedby: 'experts-emails',
|
||||
acceptNewValues: true)
|
||||
|
||||
= f.submit 'Affecter à la démarche', class: 'button primary send'
|
||||
- if @experts_procedure.present?
|
||||
%table.table.mt-2
|
||||
%thead
|
||||
%tr
|
||||
%th Liste des experts
|
||||
%th Nombre d’avis
|
||||
- if @procedure.experts_require_administrateur_invitation
|
||||
%th Notifier des décisions sur les dossiers
|
||||
%tbody
|
||||
- @experts_procedure.each do |expert_procedure|
|
||||
%tr
|
||||
%th Liste des experts
|
||||
%th Nombre d’avis
|
||||
%td
|
||||
%span.icon.person
|
||||
= expert_procedure.expert.email
|
||||
%td.text-center
|
||||
= expert_procedure.avis.count
|
||||
- if @procedure.experts_require_administrateur_invitation
|
||||
%th Notifier des décisions sur les dossiers
|
||||
%tbody
|
||||
- @experts_procedure.each do |expert_procedure|
|
||||
%tr
|
||||
%td
|
||||
%span.icon.person
|
||||
= expert_procedure.expert.email
|
||||
%td.text-center
|
||||
= expert_procedure.avis.count
|
||||
- if @procedure.experts_require_administrateur_invitation
|
||||
%td.text-center
|
||||
= form_for expert_procedure,
|
||||
url: admin_procedure_expert_path(id: expert_procedure),
|
||||
method: :put,
|
||||
data: { turbo: true },
|
||||
html: { class: 'form procedure-form__column--form no-background' } do |f|
|
||||
%label.toggle-switch{ data: { controller: 'autosubmit' } }
|
||||
= f.check_box :allow_decision_access, class: 'toggle-switch-checkbox'
|
||||
%span.toggle-switch-control.round
|
||||
%span.toggle-switch-label.on
|
||||
%span.toggle-switch-label.off
|
||||
- if @procedure.experts_require_administrateur_invitation
|
||||
%td.actions= button_to 'retirer',
|
||||
admin_procedure_expert_path(id: expert_procedure, procedure: @procedure),
|
||||
method: :delete,
|
||||
data: { confirm: "Êtes-vous sûr de vouloir révoquer l'expert « #{expert_procedure.expert.email} » de la démarche #{expert_procedure.procedure.libelle} ? Les instructeurs ne pourront plus lui demander d’avis" },
|
||||
class: 'button'
|
||||
- else
|
||||
.blank-tab
|
||||
%h2.empty-text Aucun expert invité pour le moment.
|
||||
%p.empty-text-details Les instructeurs de cette démarche n’ont pas encore fait appel aux experts.
|
||||
= form_for expert_procedure,
|
||||
url: admin_procedure_expert_path(id: expert_procedure),
|
||||
method: :put,
|
||||
data: { turbo: true },
|
||||
html: { class: 'form procedure-form__column--form no-background' } do |f|
|
||||
%label.toggle-switch{ data: { controller: 'autosubmit' } }
|
||||
= f.check_box :allow_decision_access, class: 'toggle-switch-checkbox'
|
||||
%span.toggle-switch-control.round
|
||||
%span.toggle-switch-label.on
|
||||
%span.toggle-switch-label.off
|
||||
- if @procedure.experts_require_administrateur_invitation
|
||||
%td.actions= button_to 'retirer',
|
||||
admin_procedure_expert_path(id: expert_procedure, procedure: @procedure),
|
||||
method: :delete,
|
||||
data: { confirm: "Êtes-vous sûr de vouloir révoquer l'expert « #{expert_procedure.expert.email} » de la démarche #{expert_procedure.procedure.libelle} ? Les instructeurs ne pourront plus lui demander d’avis" },
|
||||
class: 'button'
|
||||
- else
|
||||
.blank-tab
|
||||
%h2.empty-text Aucun expert invité pour le moment.
|
||||
%p.empty-text-details Les instructeurs de cette démarche n’ont pas encore fait appel aux experts.
|
||||
|
|
|
@ -18,5 +18,6 @@
|
|||
%nav.tabs
|
||||
%ul
|
||||
= dynamic_tab_item('Demande', expert_avis_path(avis.procedure, avis))
|
||||
= dynamic_tab_item('Avis', [instruction_expert_avis_path(avis.procedure, avis), avis_list_expert_avis_path(avis.procedure, avis), avis_new_expert_avis_path(avis.procedure, avis)], notification: avis.answer.blank?)
|
||||
= dynamic_tab_item('Messagerie', messagerie_expert_avis_path(avis.procedure, avis))
|
||||
= dynamic_tab_item('Avis', instruction_expert_avis_path(avis.procedure, avis), notification: avis.answer.blank?)
|
||||
- if avis.procedure.allow_expert_messaging
|
||||
= dynamic_tab_item('Messagerie', messagerie_expert_avis_path(avis.procedure, avis))
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
fr:
|
||||
administrateurs:
|
||||
experts_procedures:
|
||||
index:
|
||||
titles:
|
||||
main: Experts invités sur %{libelle}
|
||||
allow_invite_experts: "Autoriser les instructeurs à solliciter des experts invités"
|
||||
allow_expert_messaging: "Autoriser les experts à acceder à la messagerie usager"
|
||||
manage_procedure_experts: "Gérer les experts invités de la démarche"
|
||||
descriptions:
|
||||
allow_invite_experts : Lorsque cette fonctionnalité est active, les instructeurs peuvent solliciter les experts
|
||||
allow_expert_messaging: Lorsque cette fonctionnalité est active, les experts peuvent demander des informations aux usagers
|
||||
manage_procedure_experts: Lorsque cette fonctionnalité est active, les instructeurs ne peuvent uniquement solliciter les experts de votre liste
|
|
@ -488,6 +488,7 @@ Rails.application.routes.draw do
|
|||
get 'jeton'
|
||||
patch 'update_jeton'
|
||||
put :allow_expert_review
|
||||
put :allow_expert_messaging
|
||||
put :experts_require_administrateur_invitation
|
||||
put :restore
|
||||
end
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddAllowExpertMessagingToProcedures < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_column :procedures, :allow_expert_messaging, :boolean, default: true, null: false
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2023_03_03_094613) do
|
||||
ActiveRecord::Schema.define(version: 2023_03_22_150907) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "pgcrypto"
|
||||
|
@ -692,6 +692,7 @@ ActiveRecord::Schema.define(version: 2023_03_03_094613) do
|
|||
|
||||
create_table "procedures", id: :serial, force: :cascade do |t|
|
||||
t.string "aasm_state", default: "brouillon"
|
||||
t.boolean "allow_expert_messaging", default: true, null: false
|
||||
t.boolean "allow_expert_review", default: true, null: false
|
||||
t.string "api_entreprise_token"
|
||||
t.text "api_particulier_scopes", default: [], array: true
|
||||
|
|
|
@ -987,6 +987,23 @@ describe Administrateurs::ProceduresController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'PUT #allow_expert_messaging' do
|
||||
let!(:procedure) { create :procedure, :with_service, administrateur: admin }
|
||||
|
||||
context 'when admin refuse to let experts discuss with users on this procedure' do
|
||||
before do
|
||||
procedure.update!(allow_expert_messaging: false)
|
||||
procedure.reload
|
||||
end
|
||||
|
||||
it { expect(procedure.allow_expert_messaging).to be_falsy }
|
||||
end
|
||||
|
||||
context 'when admin accept to let experts discuss with users (true by default)' do
|
||||
it { expect(procedure.allow_expert_messaging).to be_truthy }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PUT #restore' do
|
||||
let(:procedure) { create :procedure_with_dossiers, :with_service, :published, administrateur: admin }
|
||||
|
||||
|
|
Loading…
Reference in a new issue