add constant for 'à_corriger'

This commit is contained in:
Lisa Durand 2023-06-19 16:04:13 +02:00
parent bcc37f4130
commit 52bbd47ebe
3 changed files with 4 additions and 3 deletions

View file

@ -15,7 +15,7 @@ class Dossiers::UserFilterComponent < ApplicationComponent
def states_collection(statut)
case statut
when 'en-cours'
(Dossier.states.values - Dossier::TERMINE) << "a_corriger"
(Dossier.states.values - Dossier::TERMINE) << Dossier::A_CORRIGER
when 'traites'
Dossier::TERMINE
end.map { |state| [t("activerecord.attributes.dossier/state.#{state}"), state] }

View file

@ -2,6 +2,7 @@ module DossierCorrectableConcern
extend ActiveSupport::Concern
included do
A_CORRIGER = 'a_corriger'
has_many :corrections, class_name: 'DossierCorrection', dependent: :destroy
scope :with_pending_corrections, -> { joins(:corrections).where(corrections: { resolved_at: nil }) }

View file

@ -21,8 +21,8 @@ class DossiersFilter
def filter_procedures(dossiers)
return dossiers if filter_params.blank?
dossiers_result = dossiers
dossiers_result = dossiers_result.where(state: state) if state.present? && state != "a_corriger"
dossiers_result = dossiers_result.with_pending_corrections if state.present? && state == "a_corriger"
dossiers_result = dossiers_result.where(state: state) if state.present? && state != Dossier::A_CORRIGER
dossiers_result = dossiers_result.with_pending_corrections if state.present? && state == Dossier::A_CORRIGER
dossiers_result = dossiers_result.where('dossiers.created_at >= ?', from_created_at_date) if from_created_at_date.present?
dossiers_result = dossiers_result.where('dossiers.depose_at >= ?', from_depose_at_date) if from_depose_at_date.present?
dossiers_result