app: move the experts list to ExpertsProceduresController
This commit is contained in:
parent
7acb4cee83
commit
c82c72402d
7 changed files with 35 additions and 20 deletions
|
@ -2,6 +2,14 @@ module NewAdministrateur
|
||||||
class ExpertsProceduresController < AdministrateurController
|
class ExpertsProceduresController < AdministrateurController
|
||||||
before_action :retrieve_procedure
|
before_action :retrieve_procedure
|
||||||
|
|
||||||
|
def index
|
||||||
|
@experts_procedure = @procedure
|
||||||
|
.experts_procedures
|
||||||
|
.where(revoked_at: nil)
|
||||||
|
.sort_by { |expert_procedure| expert_procedure.expert.email }
|
||||||
|
@experts_emails = experts_procedure_emails
|
||||||
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
emails = params['emails'].presence || [].to_json
|
emails = params['emails'].presence || [].to_json
|
||||||
emails = JSON.parse(emails).map(&:strip).map(&:downcase)
|
emails = JSON.parse(emails).map(&:strip).map(&:downcase)
|
||||||
|
@ -29,7 +37,7 @@ module NewAdministrateur
|
||||||
value: valid_users.map(&:email).join(', '),
|
value: valid_users.map(&:email).join(', '),
|
||||||
procedure: @procedure.id)
|
procedure: @procedure.id)
|
||||||
end
|
end
|
||||||
redirect_to admin_procedure_invited_expert_list_path(@procedure)
|
redirect_to admin_procedure_experts_path(@procedure)
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
@ -37,7 +45,13 @@ module NewAdministrateur
|
||||||
expert_email = expert_procedure.expert.email
|
expert_email = expert_procedure.expert.email
|
||||||
expert_procedure.update!(revoked_at: Time.zone.now)
|
expert_procedure.update!(revoked_at: Time.zone.now)
|
||||||
flash[:notice] = "#{expert_email} a été révoqué de la démarche et ne pourra plus déposer d'avis."
|
flash[:notice] = "#{expert_email} a été révoqué de la démarche et ne pourra plus déposer d'avis."
|
||||||
redirect_to admin_procedure_invited_expert_list_path(@procedure)
|
redirect_to admin_procedure_experts_path(@procedure)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def experts_procedure_emails
|
||||||
|
@procedure.experts.map(&:email).sort
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
module NewAdministrateur
|
module NewAdministrateur
|
||||||
class ProceduresController < AdministrateurController
|
class ProceduresController < AdministrateurController
|
||||||
before_action :retrieve_procedure, only: [:champs, :annotations, :edit, :monavis, :update_monavis, :jeton, :update_jeton, :publication, :publish, :transfert, :allow_expert_review, :invited_expert_list, :update_allow_decision_access]
|
before_action :retrieve_procedure, only: [:champs, :annotations, :edit, :monavis, :update_monavis, :jeton, :update_jeton, :publication, :publish, :transfert, :allow_expert_review, :update_allow_decision_access]
|
||||||
before_action :procedure_locked?, only: [:champs, :annotations]
|
before_action :procedure_locked?, only: [:champs, :annotations]
|
||||||
|
|
||||||
ITEMS_PER_PAGE = 25
|
ITEMS_PER_PAGE = 25
|
||||||
|
@ -185,11 +185,6 @@ module NewAdministrateur
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def invited_expert_list
|
|
||||||
@experts_procedure = @procedure.experts_procedures.where(revoked_at: nil).sort_by { |expert_procedure| expert_procedure.expert.email }
|
|
||||||
@experts_emails = experts_procedure_emails
|
|
||||||
end
|
|
||||||
|
|
||||||
def update_allow_decision_access
|
def update_allow_decision_access
|
||||||
@procedure
|
@procedure
|
||||||
.experts_procedures
|
.experts_procedures
|
||||||
|
@ -199,10 +194,6 @@ module NewAdministrateur
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def experts_procedure_emails
|
|
||||||
@procedure.experts.map(&:email).sort
|
|
||||||
end
|
|
||||||
|
|
||||||
def apercu_tab
|
def apercu_tab
|
||||||
params[:tab] || 'dossier'
|
params[:tab] || 'dossier'
|
||||||
end
|
end
|
||||||
|
|
|
@ -167,7 +167,7 @@
|
||||||
%p.card-admin-subtitle Liste des experts invités par les instructeurs
|
%p.card-admin-subtitle Liste des experts invités par les instructeurs
|
||||||
|
|
||||||
.card-admin-action
|
.card-admin-action
|
||||||
= link_to "Voir", admin_procedure_invited_expert_list_path(@procedure), class: 'button'
|
= link_to "Voir", admin_procedure_experts_path(@procedure), class: 'button'
|
||||||
|
|
||||||
|
|
||||||
.card-admin
|
.card-admin
|
||||||
|
|
|
@ -406,7 +406,6 @@ Rails.application.routes.draw do
|
||||||
put 'publish' => 'procedures#publish', as: :publish
|
put 'publish' => 'procedures#publish', as: :publish
|
||||||
get 'transfert' => 'procedures#transfert', as: :transfert
|
get 'transfert' => 'procedures#transfert', as: :transfert
|
||||||
post 'transfer' => 'procedures#transfer', as: :transfer
|
post 'transfer' => 'procedures#transfer', as: :transfer
|
||||||
get 'invited_expert_list'
|
|
||||||
put 'update_allow_decision_access' => 'procedures#update_allow_decision_access', as: :update_allow_decision_access
|
put 'update_allow_decision_access' => 'procedures#update_allow_decision_access', as: :update_allow_decision_access
|
||||||
resources :mail_templates, only: [:edit, :update]
|
resources :mail_templates, only: [:edit, :update]
|
||||||
|
|
||||||
|
@ -425,7 +424,7 @@ Rails.application.routes.draw do
|
||||||
|
|
||||||
resources :administrateurs, controller: 'procedure_administrateurs', only: [:index, :create, :destroy]
|
resources :administrateurs, controller: 'procedure_administrateurs', only: [:index, :create, :destroy]
|
||||||
|
|
||||||
resources :experts, controller: 'experts_procedures', only: [:create, :destroy]
|
resources :experts, controller: 'experts_procedures', only: [:index, :create, :destroy]
|
||||||
|
|
||||||
resources :types_de_champ, only: [:create, :update, :destroy] do
|
resources :types_de_champ, only: [:create, :update, :destroy] do
|
||||||
member do
|
member do
|
||||||
|
|
|
@ -1,12 +1,24 @@
|
||||||
describe NewAdministrateur::ExpertsProceduresController, type: :controller do
|
describe NewAdministrateur::ExpertsProceduresController, type: :controller do
|
||||||
let(:admin) { create(:administrateur) }
|
let(:admin) { create(:administrateur) }
|
||||||
|
let(:procedure) { create :procedure, administrateur: admin }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
sign_in(admin.user)
|
sign_in(admin.user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#index' do
|
||||||
|
subject do
|
||||||
|
get :index, params: { procedure_id: procedure.id }
|
||||||
|
end
|
||||||
|
|
||||||
|
before do
|
||||||
|
subject
|
||||||
|
end
|
||||||
|
|
||||||
|
it { expect(response.status).to eq 200 }
|
||||||
|
end
|
||||||
|
|
||||||
describe '#create' do
|
describe '#create' do
|
||||||
let(:procedure) { create :procedure, administrateur: admin }
|
|
||||||
let(:expert) { create(:expert) }
|
let(:expert) { create(:expert) }
|
||||||
let(:expert2) { create(:expert) }
|
let(:expert2) { create(:expert) }
|
||||||
|
|
||||||
|
@ -25,12 +37,11 @@ describe NewAdministrateur::ExpertsProceduresController, type: :controller do
|
||||||
it { expect(procedure.experts.include?(expert)).to be_truthy }
|
it { expect(procedure.experts.include?(expert)).to be_truthy }
|
||||||
it { expect(procedure.experts.include?(expert2)).to be_truthy }
|
it { expect(procedure.experts.include?(expert2)).to be_truthy }
|
||||||
it { expect(flash.notice).to be_present }
|
it { expect(flash.notice).to be_present }
|
||||||
it { expect(response).to redirect_to(admin_procedure_invited_expert_list_path(procedure)) }
|
it { expect(response).to redirect_to(admin_procedure_experts_path(procedure)) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#delete' do
|
describe '#delete' do
|
||||||
let(:procedure) { create :procedure, administrateur: admin }
|
|
||||||
let(:expert) { create(:expert) }
|
let(:expert) { create(:expert) }
|
||||||
let(:expert_procedure) { ExpertsProcedure.create(expert: expert, procedure: procedure) }
|
let(:expert_procedure) { ExpertsProcedure.create(expert: expert, procedure: procedure) }
|
||||||
|
|
||||||
|
@ -46,7 +57,7 @@ describe NewAdministrateur::ExpertsProceduresController, type: :controller do
|
||||||
context 'of multiple experts' do
|
context 'of multiple experts' do
|
||||||
it { expect(expert_procedure.revoked_at).to be_present }
|
it { expect(expert_procedure.revoked_at).to be_present }
|
||||||
it { expect(flash.notice).to be_present }
|
it { expect(flash.notice).to be_present }
|
||||||
it { expect(response).to redirect_to(admin_procedure_invited_expert_list_path(procedure)) }
|
it { expect(response).to redirect_to(admin_procedure_experts_path(procedure)) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
describe 'new_administrateur/procedures/invited_expert_list.html.haml', type: :view do
|
describe 'new_administrateur/experts_procedures/index.html.haml', type: :view do
|
||||||
let!(:procedure) { create(:procedure, :published) }
|
let!(:procedure) { create(:procedure, :published) }
|
||||||
|
|
||||||
before do
|
before do
|
Loading…
Reference in a new issue