Group the Dossier scopes and move them at the top
This commit is contained in:
parent
6731f28e23
commit
1816aef7d0
1 changed files with 13 additions and 16 deletions
|
@ -40,6 +40,19 @@ class Dossier < ActiveRecord::Base
|
||||||
belongs_to :procedure
|
belongs_to :procedure
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
|
|
||||||
|
scope :brouillon, -> { where(state: BROUILLON) }
|
||||||
|
scope :not_brouillon, -> { where.not(state: BROUILLON) }
|
||||||
|
scope :en_construction, -> { where(state: EN_CONSTRUCTION) }
|
||||||
|
scope :en_instruction, -> { where(state: EN_INSTRUCTION) }
|
||||||
|
scope :termine, -> { where(state: TERMINE) }
|
||||||
|
|
||||||
|
scope :archived, -> { where(archived: true) }
|
||||||
|
scope :not_archived, -> { where(archived: false) }
|
||||||
|
|
||||||
|
scope :order_by_updated_at, -> (order = :desc) { order(updated_at: order) }
|
||||||
|
|
||||||
|
scope :downloadable, -> { not_brouillon.order_by_updated_at("ASC") }
|
||||||
|
|
||||||
accepts_nested_attributes_for :individual
|
accepts_nested_attributes_for :individual
|
||||||
|
|
||||||
delegate :siren, to: :entreprise
|
delegate :siren, to: :entreprise
|
||||||
|
@ -166,11 +179,6 @@ class Dossier < ActiveRecord::Base
|
||||||
BROUILLON.include?(state)
|
BROUILLON.include?(state)
|
||||||
end
|
end
|
||||||
|
|
||||||
scope :brouillon, -> { where(state: BROUILLON) }
|
|
||||||
scope :not_brouillon, -> { where.not(state: BROUILLON) }
|
|
||||||
|
|
||||||
scope :order_by_updated_at, -> (order = :desc) { order(updated_at: order) }
|
|
||||||
|
|
||||||
def self.nouveaux order = 'ASC'
|
def self.nouveaux order = 'ASC'
|
||||||
not_archived.where(state: NOUVEAUX).order_by_updated_at(order)
|
not_archived.where(state: NOUVEAUX).order_by_updated_at(order)
|
||||||
end
|
end
|
||||||
|
@ -183,8 +191,6 @@ class Dossier < ActiveRecord::Base
|
||||||
not_archived.where(state: WAITING_FOR_USER).order_by_updated_at(order)
|
not_archived.where(state: WAITING_FOR_USER).order_by_updated_at(order)
|
||||||
end
|
end
|
||||||
|
|
||||||
scope :en_construction, -> { where(state: EN_CONSTRUCTION) }
|
|
||||||
|
|
||||||
def self.ouvert order = 'ASC'
|
def self.ouvert order = 'ASC'
|
||||||
not_archived.where(state: OUVERT).order_by_updated_at(order)
|
not_archived.where(state: OUVERT).order_by_updated_at(order)
|
||||||
end
|
end
|
||||||
|
@ -193,15 +199,6 @@ class Dossier < ActiveRecord::Base
|
||||||
not_archived.where(state: A_INSTRUIRE).order_by_updated_at(order)
|
not_archived.where(state: A_INSTRUIRE).order_by_updated_at(order)
|
||||||
end
|
end
|
||||||
|
|
||||||
scope :en_instruction, -> { where(state: EN_INSTRUCTION) }
|
|
||||||
|
|
||||||
scope :termine, -> { where(state: TERMINE) }
|
|
||||||
|
|
||||||
scope :archived, -> { where(archived: true) }
|
|
||||||
scope :not_archived, -> { where(archived: false) }
|
|
||||||
|
|
||||||
scope :downloadable, -> { not_brouillon.order_by_updated_at("ASC") }
|
|
||||||
|
|
||||||
def cerfa_available?
|
def cerfa_available?
|
||||||
procedure.cerfa_flag? && cerfa.size != 0
|
procedure.cerfa_flag? && cerfa.size != 0
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue