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:
Colin Darie 2024-03-12 14:09:48 +00:00 committed by GitHub
commit 0d2f5547e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 12 additions and 9 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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' }

View file

@ -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