Dossier: remove useless state methods and const
This commit is contained in:
parent
a1426ec56d
commit
7cc69de543
1 changed files with 7 additions and 23 deletions
|
@ -8,11 +8,7 @@ class Dossier < ActiveRecord::Base
|
|||
sans_suite: 'sans_suite'
|
||||
}
|
||||
|
||||
BROUILLON = %w(brouillon)
|
||||
NOUVEAUX = %w(en_construction)
|
||||
EN_CONSTRUCTION = %w(en_construction)
|
||||
EN_INSTRUCTION = %w(en_instruction)
|
||||
EN_CONSTRUCTION_OU_INSTRUCTION = EN_CONSTRUCTION + EN_INSTRUCTION
|
||||
EN_CONSTRUCTION_OU_INSTRUCTION = %w(en_construction en_instruction)
|
||||
TERMINE = %w(accepte refuse sans_suite)
|
||||
|
||||
has_one :etablissement, dependent: :destroy
|
||||
|
@ -41,11 +37,11 @@ class Dossier < ActiveRecord::Base
|
|||
accepts_nested_attributes_for :champs_private
|
||||
|
||||
default_scope { where(hidden_at: nil) }
|
||||
scope :state_brouillon, -> { where(state: BROUILLON) }
|
||||
scope :state_not_brouillon, -> { where.not(state: BROUILLON) }
|
||||
scope :state_nouveaux, -> { where(state: NOUVEAUX) }
|
||||
scope :state_en_construction, -> { where(state: EN_CONSTRUCTION) }
|
||||
scope :state_en_instruction, -> { where(state: EN_INSTRUCTION) }
|
||||
scope :state_brouillon, -> { where(state: 'brouillon') }
|
||||
scope :state_not_brouillon, -> { where.not(state: 'brouillon') }
|
||||
scope :state_nouveaux, -> { where(state: 'en_construction') }
|
||||
scope :state_en_construction, -> { where(state: 'en_construction') }
|
||||
scope :state_en_instruction, -> { where(state: 'en_instruction') }
|
||||
scope :state_en_construction_ou_instruction, -> { where(state: EN_CONSTRUCTION_OU_INSTRUCTION) }
|
||||
scope :state_termine, -> { where(state: TERMINE) }
|
||||
|
||||
|
@ -144,18 +140,6 @@ class Dossier < ActiveRecord::Base
|
|||
champs.joins(', types_de_piece_justificative').where("pieces_justificatives.type_de_piece_justificative_id = types_de_piece_justificative.id AND types_de_piece_justificative.procedure_id = #{procedure.id}").order('order_place ASC')
|
||||
end
|
||||
|
||||
def brouillon?
|
||||
BROUILLON.include?(state)
|
||||
end
|
||||
|
||||
def en_construction?
|
||||
EN_CONSTRUCTION.include?(state)
|
||||
end
|
||||
|
||||
def en_instruction?
|
||||
EN_INSTRUCTION.include?(state)
|
||||
end
|
||||
|
||||
def en_construction_ou_instruction?
|
||||
EN_CONSTRUCTION_OU_INSTRUCTION.include?(state)
|
||||
end
|
||||
|
@ -347,7 +331,7 @@ class Dossier < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def send_dossier_received
|
||||
if state_changed? && EN_INSTRUCTION.include?(state)
|
||||
if state_changed? && en_instruction?
|
||||
NotificationMailer.send_dossier_received(id).deliver_later
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue