From a050bc20dee8410451e9924d8d7e4337e5f4b868 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Tue, 16 Jan 2018 09:23:20 +0100 Subject: [PATCH 1/3] Add a dossiers_from_avis relation to Gestionnaire --- app/models/gestionnaire.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/gestionnaire.rb b/app/models/gestionnaire.rb index f28ffc1ee..65034cc43 100644 --- a/app/models/gestionnaire.rb +++ b/app/models/gestionnaire.rb @@ -10,6 +10,7 @@ class Gestionnaire < ActiveRecord::Base has_many :followed_dossiers, through: :follows, source: :dossier has_many :follows has_many :avis + has_many :dossiers_from_avis, through: :avis, source: :dossier include CredentialsSyncableConcern From d33d488db7d2dca884ab36c0ea04b43092f65e73 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Tue, 16 Jan 2018 09:25:23 +0100 Subject: [PATCH 2/3] Avoid EOL if statements --- app/controllers/new_gestionnaire/recherche_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/new_gestionnaire/recherche_controller.rb b/app/controllers/new_gestionnaire/recherche_controller.rb index 243e0d55b..4073b32c8 100644 --- a/app/controllers/new_gestionnaire/recherche_controller.rb +++ b/app/controllers/new_gestionnaire/recherche_controller.rb @@ -8,7 +8,9 @@ module NewGestionnaire @dossiers = current_gestionnaire.dossiers.where(id: @search_terms.to_i) end - @dossiers = Dossier.none if @dossiers.nil? + if @dossiers.nil? + @dossiers = Dossier.none + end # full text search if @dossiers.empty? From 16254899e1d8667157f429dbdc03be72fa775a07 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Tue, 16 Jan 2018 09:27:32 +0100 Subject: [PATCH 3/3] [Fix #1199] Make id search work for experts --- app/controllers/new_gestionnaire/recherche_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/new_gestionnaire/recherche_controller.rb b/app/controllers/new_gestionnaire/recherche_controller.rb index 4073b32c8..0f7dcf159 100644 --- a/app/controllers/new_gestionnaire/recherche_controller.rb +++ b/app/controllers/new_gestionnaire/recherche_controller.rb @@ -5,7 +5,9 @@ module NewGestionnaire # exact id match? if @search_terms.to_i != 0 - @dossiers = current_gestionnaire.dossiers.where(id: @search_terms.to_i) + @dossiers = current_gestionnaire.dossiers.where(id: @search_terms.to_i) + + current_gestionnaire.dossiers_from_avis.where(id: @search_terms.to_i) + @dossiers.uniq! end if @dossiers.nil?