add the possibility for administrator to refuse external review on a specific procedure
This commit is contained in:
parent
1ba85e6080
commit
57adb90c8f
8 changed files with 52 additions and 3 deletions
|
@ -1,6 +1,6 @@
|
|||
module NewAdministrateur
|
||||
class ProceduresController < AdministrateurController
|
||||
before_action :retrieve_procedure, only: [:champs, :annotations, :edit, :monavis, :update_monavis, :jeton, :update_jeton, :publication, :publish, :transfert]
|
||||
before_action :retrieve_procedure, only: [:champs, :annotations, :edit, :monavis, :update_monavis, :jeton, :update_jeton, :publication, :publish, :transfert, :allow_expert_review]
|
||||
before_action :procedure_locked?, only: [:champs, :annotations]
|
||||
|
||||
ITEMS_PER_PAGE = 25
|
||||
|
@ -158,6 +158,12 @@ module NewAdministrateur
|
|||
def transfert
|
||||
end
|
||||
|
||||
def allow_expert_review
|
||||
@procedure.update!(allow_expert_review: !@procedure.allow_expert_review)
|
||||
flash.notice = @procedure.allow_expert_review? ? "Avis externes activés" : "Avis externes désactivés"
|
||||
redirect_to admin_procedure_path(@procedure)
|
||||
end
|
||||
|
||||
def transfer
|
||||
admin = Administrateur.by_email(params[:email_admin].downcase)
|
||||
if admin.nil?
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#
|
||||
# id :integer not null, primary key
|
||||
# aasm_state :string default("brouillon")
|
||||
# allow_expert_review :boolean default(TRUE), not null
|
||||
# api_entreprise_token :string
|
||||
# ask_birthday :boolean default(FALSE), not null
|
||||
# auto_archive_on :date
|
||||
|
|
|
@ -4,7 +4,10 @@
|
|||
|
||||
.container
|
||||
- if !@dossier.termine?
|
||||
= render partial: "instructeurs/shared/avis/form", locals: { url: avis_instructeur_dossier_path(@dossier.procedure, @dossier), linked_dossiers: @dossier.linked_dossiers_for(current_instructeur), must_be_confidentiel: false, avis: @avis }
|
||||
- if @dossier.procedure.allow_expert_review
|
||||
= render partial: "instructeurs/shared/avis/form", locals: { url: avis_instructeur_dossier_path(@dossier.procedure, @dossier), linked_dossiers: @dossier.linked_dossiers_for(current_instructeur), must_be_confidentiel: false, avis: @avis }
|
||||
- else
|
||||
%p Cette démarche n'autorise pas la demande d'avis à un expert. Veuillez contacter votre administrateur
|
||||
|
||||
- if @dossier.avis.present?
|
||||
= render partial: 'instructeurs/shared/avis/list', locals: { avis: @dossier.avis, avis_seen_at: @avis_seen_at }
|
||||
|
|
|
@ -139,6 +139,21 @@
|
|||
.card-admin-action
|
||||
= link_to 'Modifier', edit_admin_procedure_attestation_template_path(@procedure), class: 'button'
|
||||
|
||||
.card-admin
|
||||
- if @procedure.allow_expert_review?
|
||||
%div
|
||||
%span.icon.accept
|
||||
%p.card-admin-status-accept Activé
|
||||
- else
|
||||
%div
|
||||
%span.icon.clock
|
||||
%p.card-admin-status-todo Désactivée
|
||||
%div
|
||||
%p.card-admin-title Avis externes
|
||||
%p.card-admin-subtitle Demander des avis aux experts invités
|
||||
.card-admin-action
|
||||
= link_to "#{@procedure.allow_expert_review? ? 'Désactiver' : 'Activer'}", allow_expert_review_admin_procedure_path(@procedure), method: :put, class: 'button'
|
||||
|
||||
.card-admin
|
||||
%div
|
||||
%span.icon.clock
|
||||
|
|
|
@ -365,6 +365,7 @@ Rails.application.routes.draw do
|
|||
patch 'update_monavis'
|
||||
get 'jeton'
|
||||
patch 'update_jeton'
|
||||
put :allow_expert_review
|
||||
end
|
||||
|
||||
get 'publication' => 'procedures#publication', as: :publication
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddAllowInstructorInviteExpert < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
add_column :procedures, :allow_expert_review, :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: 2020_09_02_103047) do
|
||||
ActiveRecord::Schema.define(version: 2020_09_30_143755) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -543,6 +543,7 @@ ActiveRecord::Schema.define(version: 2020_09_02_103047) do
|
|||
t.string "api_entreprise_token"
|
||||
t.bigint "draft_revision_id"
|
||||
t.bigint "published_revision_id"
|
||||
t.boolean "allow_expert_review", default: true, null: false
|
||||
t.index ["declarative_with_state"], name: "index_procedures_on_declarative_with_state"
|
||||
t.index ["draft_revision_id"], name: "index_procedures_on_draft_revision_id"
|
||||
t.index ["hidden_at"], name: "index_procedures_on_hidden_at"
|
||||
|
|
|
@ -488,4 +488,21 @@ describe NewAdministrateur::ProceduresController, type: :controller do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PUT #allow_expert_review' do
|
||||
let!(:procedure) { create :procedure, :with_service, administrateur: admin }
|
||||
|
||||
context 'when admin refuse to invite experts on this procedure' do
|
||||
before do
|
||||
procedure.update!(allow_expert_review: false)
|
||||
procedure.reload
|
||||
end
|
||||
|
||||
it { expect(procedure.allow_expert_review).to be_falsy }
|
||||
end
|
||||
|
||||
context 'when admin accept to invite experts on this procedure (true by default)' do
|
||||
it { expect(procedure.allow_expert_review).to be_truthy }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue