Merge pull request #10076 from mfo/US/fix-expert-dossier-export
correctif(Export.export): ETQ expert téléchargeant un dossier et toutes ses PJs, la messagerie n'est pas dans l'export quand la procedure ne l'autorise pas. L'export ne contient pas les annotations privées
This commit is contained in:
commit
0d2f5547e0
7 changed files with 12 additions and 9 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_infos_administration: true,
|
||||
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' }
|
||||
|
||||
|
|
|
@ -1132,7 +1132,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