models: add a Dossier#with_hidden scope, and remove unscoped usages

This commit is contained in:
Pierre de La Morinerie 2020-01-28 16:55:07 +01:00
parent 1448d5b098
commit 96932faa3f
10 changed files with 39 additions and 19 deletions

View file

@ -95,6 +95,8 @@ class Dossier < ApplicationRecord
end
default_scope { where(hidden_at: nil) }
scope :hidden, -> { unscope(where: :hidden_at).where.not(hidden_at: nil) }
scope :with_hidden, -> { unscope(where: :hidden_at) }
scope :state_brouillon, -> { where(state: states.fetch(:brouillon)) }
scope :state_not_brouillon, -> { where.not(state: states.fetch(:brouillon)) }
scope :state_en_construction, -> { where(state: states.fetch(:en_construction)) }