Merge pull request #8002 from demarches-simplifiees/add-message-for-instructors-in-search
it displays a message if instructor is looking for a dossier that is not in his instructor group
This commit is contained in:
commit
24c0473226
5 changed files with 45 additions and 0 deletions
|
@ -28,6 +28,23 @@ class RechercheController < ApplicationController
|
||||||
@dossiers_count = matching_dossiers_ids.count
|
@dossiers_count = matching_dossiers_ids.count
|
||||||
@followed_dossiers_id = current_instructeur&.followed_dossiers&.where(id: @paginated_ids)&.ids || []
|
@followed_dossiers_id = current_instructeur&.followed_dossiers&.where(id: @paginated_ids)&.ids || []
|
||||||
@dossier_avis_ids_h = current_expert&.avis&.where(dossier_id: @paginated_ids)&.pluck(:dossier_id, :id).to_h || {}
|
@dossier_avis_ids_h = current_expert&.avis&.where(dossier_id: @paginated_ids)&.pluck(:dossier_id, :id).to_h || {}
|
||||||
|
|
||||||
|
# if an instructor search for a dossier which is in his procedures but not available to his intructor group
|
||||||
|
# we want to display an alert in view
|
||||||
|
|
||||||
|
# to make it simpler we only do it if the @search_terms is an id
|
||||||
|
return if !DossierSearchService.id_compatible?(@search_terms)
|
||||||
|
|
||||||
|
dossier_instructeur_searched_for = Dossier.find_by(id: @search_terms)
|
||||||
|
|
||||||
|
return if dossier_instructeur_searched_for.nil?
|
||||||
|
return if current_instructeur&.groupe_instructeur_ids&.include?(dossier_instructeur_searched_for.groupe_instructeur_id)
|
||||||
|
|
||||||
|
if current_instructeur&.procedures&.include?(dossier_instructeur_searched_for.procedure)
|
||||||
|
@dossier_not_in_instructor_group = dossier_instructeur_searched_for
|
||||||
|
else
|
||||||
|
return
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
- content_for(:title, "Recherche : #{@search_terms}")
|
- content_for(:title, "Recherche : #{@search_terms}")
|
||||||
|
|
||||||
.container
|
.container
|
||||||
|
|
||||||
|
- if @dossier_not_in_instructor_group.present?
|
||||||
|
.fr-alert.fr-alert--info.fr-alert--sm.fr-mt-3w
|
||||||
|
= p t('views.instructeurs.search.dossier_not_in_instructor_group', dossier_id: @dossier_not_in_instructor_group.id, procedure_libelle: @dossier_not_in_instructor_group.procedure.libelle, groupe_instructeur_label: @dossier_not_in_instructor_group.groupe_instructeur.label)
|
||||||
|
|
||||||
.page-title
|
.page-title
|
||||||
Résultat de la recherche :
|
Résultat de la recherche :
|
||||||
= t('pluralize.dossier_trouve', count: @dossiers_count)
|
= t('pluralize.dossier_trouve', count: @dossiers_count)
|
||||||
|
|
|
@ -182,6 +182,8 @@ en:
|
||||||
dossier_synthesis: Summary of files
|
dossier_synthesis: Summary of files
|
||||||
avis:
|
avis:
|
||||||
introduction_file_explaination: "File attached to the request for advice"
|
introduction_file_explaination: "File attached to the request for advice"
|
||||||
|
search:
|
||||||
|
dossier_not_in_instructor_group: "File no. %{dossier_id} of the “%{procedure_libelle}” procedure corresponds to your search, but it is attached to the “%{groupe_instructeur_label}” instructor group."
|
||||||
users:
|
users:
|
||||||
dossiers:
|
dossiers:
|
||||||
archived_dossier: "Your file will be kept %{duree_conservation_dossiers_dans_ds} more months"
|
archived_dossier: "Your file will be kept %{duree_conservation_dossiers_dans_ds} more months"
|
||||||
|
|
|
@ -178,6 +178,8 @@ fr:
|
||||||
dossier_synthesis: Synthèse des dossiers
|
dossier_synthesis: Synthèse des dossiers
|
||||||
avis:
|
avis:
|
||||||
introduction_file_explaination: "Fichier joint à la demande d’avis"
|
introduction_file_explaination: "Fichier joint à la demande d’avis"
|
||||||
|
search:
|
||||||
|
dossier_not_in_instructor_group: "Le dossier n° %{dossier_id} de la procédure « %{procedure_libelle} » correspond à votre recherche mais il est rattaché au groupe d'instructeurs « %{groupe_instructeur_label} »."
|
||||||
users:
|
users:
|
||||||
dossiers:
|
dossiers:
|
||||||
archived_dossier: "Votre dossier sera conservé %{duree_conservation_dossiers_dans_ds} mois supplémentaire"
|
archived_dossier: "Votre dossier sera conservé %{duree_conservation_dossiers_dans_ds} mois supplémentaire"
|
||||||
|
|
|
@ -74,6 +74,25 @@ describe RechercheController, type: :controller do
|
||||||
it 'does not return the dossier' do
|
it 'does not return the dossier' do
|
||||||
subject
|
subject
|
||||||
expect(assigns(:projected_dossiers).count).to eq(0)
|
expect(assigns(:projected_dossiers).count).to eq(0)
|
||||||
|
expect(assigns(:dossier_not_in_instructor_group)).to eq(nil)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when instructeur is attached to the procedure but is not in the instructor group of the dossier' do
|
||||||
|
let!(:gi_p1_1) { GroupeInstructeur.create(label: 'groupe 1', procedure: procedure) }
|
||||||
|
let!(:gi_p1_2) { GroupeInstructeur.create(label: 'groupe 2', procedure: procedure) }
|
||||||
|
let!(:dossier3) { create(:dossier, :accepte, :with_individual, procedure: procedure, groupe_instructeur: gi_p1_2) }
|
||||||
|
|
||||||
|
before { gi_p1_1.instructeurs << instructeur }
|
||||||
|
|
||||||
|
let(:query) { dossier3.id }
|
||||||
|
|
||||||
|
it { is_expected.to have_http_status(200) }
|
||||||
|
|
||||||
|
it 'does not return the dossier but it returns a message' do
|
||||||
|
subject
|
||||||
|
expect(assigns(:projected_dossiers).count).to eq(0)
|
||||||
|
expect(assigns(:dossier_not_in_instructor_group)).to eq(dossier3)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue