refactor(procedure_presentation): use internal reference to instructeur
This commit is contained in:
parent
f71c89aa91
commit
6da54936b7
4 changed files with 9 additions and 6 deletions
|
@ -111,7 +111,7 @@ module Instructeurs
|
||||||
@has_termine_notifications = notifications[:termines].present?
|
@has_termine_notifications = notifications[:termines].present?
|
||||||
@not_archived_notifications_dossier_ids = notifications[:en_cours] + notifications[:termines]
|
@not_archived_notifications_dossier_ids = notifications[:en_cours] + notifications[:termines]
|
||||||
|
|
||||||
sorted_ids = procedure_presentation.sorted_ids(@dossiers, dossiers_count, current_instructeur)
|
sorted_ids = procedure_presentation.sorted_ids(@dossiers, dossiers_count)
|
||||||
|
|
||||||
if @current_filters.count > 0
|
if @current_filters.count > 0
|
||||||
filtered_ids = procedure_presentation.filtered_ids(@dossiers, statut)
|
filtered_ids = procedure_presentation.filtered_ids(@dossiers, statut)
|
||||||
|
|
|
@ -110,7 +110,11 @@ class Instructeur < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def procedure_presentation_and_errors_for_procedure_id(procedure_id)
|
def procedure_presentation_and_errors_for_procedure_id(procedure_id)
|
||||||
assign_to.joins(:groupe_instructeur).find_by(groupe_instructeurs: { procedure_id: procedure_id }).procedure_presentation_or_default_and_errors
|
assign_to
|
||||||
|
.joins(:groupe_instructeur)
|
||||||
|
.includes(:instructeur, :procedure)
|
||||||
|
.find_by(groupe_instructeurs: { procedure_id: procedure_id })
|
||||||
|
.procedure_presentation_or_default_and_errors
|
||||||
end
|
end
|
||||||
|
|
||||||
def notifications_for_dossier(dossier)
|
def notifications_for_dossier(dossier)
|
||||||
|
|
|
@ -25,8 +25,7 @@ class ProcedurePresentation < ApplicationRecord
|
||||||
FILTERS_VALUE_MAX_LENGTH = 100
|
FILTERS_VALUE_MAX_LENGTH = 100
|
||||||
|
|
||||||
belongs_to :assign_to, optional: false
|
belongs_to :assign_to, optional: false
|
||||||
|
delegate :procedure, :instructeur, to: :assign_to
|
||||||
delegate :procedure, to: :assign_to
|
|
||||||
|
|
||||||
validate :check_allowed_displayed_fields
|
validate :check_allowed_displayed_fields
|
||||||
validate :check_allowed_sort_column
|
validate :check_allowed_sort_column
|
||||||
|
@ -84,7 +83,7 @@ class ProcedurePresentation < ApplicationRecord
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
def sorted_ids(dossiers, count, instructeur)
|
def sorted_ids(dossiers, count)
|
||||||
table, column, order = sort.values_at(TABLE, COLUMN, 'order')
|
table, column, order = sort.values_at(TABLE, COLUMN, 'order')
|
||||||
|
|
||||||
case table
|
case table
|
||||||
|
|
|
@ -133,7 +133,7 @@ describe ProcedurePresentation do
|
||||||
let(:sort) { { 'table' => table, 'column' => column, 'order' => order } }
|
let(:sort) { { 'table' => table, 'column' => column, 'order' => order } }
|
||||||
let(:procedure_presentation) { create(:procedure_presentation, assign_to: assign_to, sort: sort) }
|
let(:procedure_presentation) { create(:procedure_presentation, assign_to: assign_to, sort: sort) }
|
||||||
|
|
||||||
subject { procedure_presentation.sorted_ids(procedure.dossiers, procedure.dossiers.count, instructeur) }
|
subject { procedure_presentation.sorted_ids(procedure.dossiers, procedure.dossiers.count) }
|
||||||
|
|
||||||
context 'for notifications table' do
|
context 'for notifications table' do
|
||||||
let(:table) { 'notifications' }
|
let(:table) { 'notifications' }
|
||||||
|
|
Loading…
Add table
Reference in a new issue