fix(export.pdf): expert should not have access to messagerie when it was disabled
This commit is contained in:
parent
84f995bd47
commit
f4d2f1ddf5
7 changed files with 11 additions and 8 deletions
|
@ -2,7 +2,7 @@ class API::V2::DossiersController < API::V2::BaseController
|
|||
before_action :ensure_dossier_present
|
||||
|
||||
def pdf
|
||||
@acls = PiecesJustificativesService.new(user_profile: Administrateur.new).acl_for_dossier_export
|
||||
@acls = PiecesJustificativesService.new(user_profile: Administrateur.new).acl_for_dossier_export(dossier.procedure)
|
||||
render(template: 'dossiers/show', formats: [:pdf])
|
||||
end
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ module Instructeurs
|
|||
@is_dossier_in_batch_operation = dossier.batch_operation.present?
|
||||
respond_to do |format|
|
||||
format.pdf do
|
||||
@acls = PiecesJustificativesService.new(user_profile: current_instructeur).acl_for_dossier_export
|
||||
@acls = PiecesJustificativesService.new(user_profile: current_instructeur).acl_for_dossier_export(dossier.procedure)
|
||||
render(template: 'dossiers/show', formats: [:pdf])
|
||||
end
|
||||
format.all
|
||||
|
|
|
@ -92,7 +92,7 @@ module Users
|
|||
respond_to do |format|
|
||||
format.pdf do
|
||||
@dossier = dossier_with_champs(pj_template: false)
|
||||
@acls = pj_service.acl_for_dossier_export
|
||||
@acls = pj_service.acl_for_dossier_export(@dossier.procedure)
|
||||
render(template: 'dossiers/show', formats: [:pdf])
|
||||
end
|
||||
format.all do
|
||||
|
|
|
@ -46,7 +46,7 @@ class PiecesJustificativesService
|
|||
pdf = ApplicationController
|
||||
.render(template: 'dossiers/show', formats: [:pdf],
|
||||
assigns: {
|
||||
acls: acl_for_dossier_export,
|
||||
acls: acl_for_dossier_export(procedure),
|
||||
dossier: dossier
|
||||
})
|
||||
|
||||
|
@ -81,22 +81,25 @@ class PiecesJustificativesService
|
|||
end
|
||||
end
|
||||
|
||||
def acl_for_dossier_export
|
||||
def acl_for_dossier_export(procedure)
|
||||
case @user_profile
|
||||
when Expert
|
||||
{
|
||||
include_messagerie: procedure.allow_expert_messaging,
|
||||
include_infos_administration: false,
|
||||
include_avis_for_expert: true,
|
||||
only_for_expert: @user_profile
|
||||
}
|
||||
when Instructeur, Administrateur
|
||||
{
|
||||
include_messagerie: true,
|
||||
include_infos_administration: true,
|
||||
include_avis_for_expert: true,
|
||||
only_for_export: false
|
||||
}
|
||||
when User
|
||||
{
|
||||
include_messagerie: true,
|
||||
include_infos_administration: false,
|
||||
include_avis_for_expert: false, # should be true, expert can use the messagerie, why not provide avis ?
|
||||
only_for_expert: false
|
||||
|
|
|
@ -374,7 +374,7 @@ prawn_document(page_size: "A4") do |pdf|
|
|||
end
|
||||
end
|
||||
|
||||
if @dossier.commentaires.present?
|
||||
if @acls[:include_messagerie] && @dossier.commentaires.present?
|
||||
add_title(pdf, 'Messagerie')
|
||||
@dossier.commentaires.each do |commentaire|
|
||||
add_message(pdf, commentaire)
|
||||
|
|
|
@ -910,7 +910,7 @@ describe Instructeurs::DossiersController, type: :controller do
|
|||
subject
|
||||
end
|
||||
|
||||
it { expect(assigns(:acls)).to eq(PiecesJustificativesService.new(user_profile: instructeur).acl_for_dossier_export) }
|
||||
it { expect(assigns(:acls)).to eq(PiecesJustificativesService.new(user_profile: instructeur).acl_for_dossier_export(dossier.procedure)) }
|
||||
it { expect(assigns(:is_dossier_in_batch_operation)).to eq(false) }
|
||||
it { expect(response).to render_template 'dossiers/show' }
|
||||
|
||||
|
|
|
@ -1114,7 +1114,7 @@ describe Users::DossiersController, type: :controller do
|
|||
end
|
||||
|
||||
context 'when the dossier has been submitted' do
|
||||
it { expect(assigns(:acls)).to eq(PiecesJustificativesService.new(user_profile: user).acl_for_dossier_export) }
|
||||
it { expect(assigns(:acls)).to eq(PiecesJustificativesService.new(user_profile: user).acl_for_dossier_export(dossier.procedure)) }
|
||||
it { expect(response).to render_template('dossiers/show') }
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue