|
|
@ -57,10 +57,12 @@ class Node < ApplicationRecord |
|
|
|
|
|
|
|
|
# scope :not_excluded, -> { where "NOT(? = ANY (excluded_locales))", I18n.locale.to_s } |
|
|
# scope :not_excluded, -> { where "NOT(? = ANY (excluded_locales))", I18n.locale.to_s } |
|
|
|
|
|
|
|
|
scope :for_current_locale, -> { where("(cardinality(excluded_locales) = 0 AND is_allowlist = false) OR |
|
|
|
|
|
(is_allowlist = true AND ? = ANY(excluded_locales)) OR |
|
|
|
|
|
(is_allowlist = false AND NOT(? = ANY(excluded_locales)))", |
|
|
|
|
|
I18n.locale.to_s, I18n.locale.to_s ) } |
|
|
|
|
|
|
|
|
scope :for_current_locale, -> { |
|
|
|
|
|
where("(cardinality(excluded_locales) = 0 AND is_allowlist = false) OR |
|
|
|
|
|
(is_allowlist = true AND ? = ANY(excluded_locales)) OR |
|
|
|
|
|
(is_allowlist = false AND NOT(? = ANY(excluded_locales)))", |
|
|
|
|
|
I18n.locale.to_s, I18n.locale.to_s ) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
scope :viewable, -> { status_published.for_current_locale.where('published_at <= ? AND (expires_at IS NULL OR expires_at > ?)', Time.current, Time.current) } |
|
|
scope :viewable, -> { status_published.for_current_locale.where('published_at <= ? AND (expires_at IS NULL OR expires_at > ?)', Time.current, Time.current) } |
|
|
scope :of_template, ->(tmpl) { where(template: Node.templates[tmpl.to_s]) } |
|
|
scope :of_template, ->(tmpl) { where(template: Node.templates[tmpl.to_s]) } |
|
|
|