diff options
Diffstat (limited to 'app/models/node.rb')
| -rw-r--r-- | app/models/node.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/app/models/node.rb b/app/models/node.rb index 8d0756a..19669ca 100644 --- a/app/models/node.rb +++ b/app/models/node.rb | |||
| @@ -35,6 +35,14 @@ class Node < ApplicationRecord | |||
| 35 | :allow_nil => true, | 35 | :allow_nil => true, |
| 36 | :if => :default_template_name_changed? | 36 | :if => :default_template_name_changed? |
| 37 | 37 | ||
| 38 | # Everything outside the Trash subtree, the Trash node included. | ||
| 39 | # Relies on unique_name being authoritative for tree position -- | ||
| 40 | # the same trust public routing places in it. | ||
| 41 | scope :not_in_trash, -> { | ||
| 42 | where.not(:unique_name => CccConventions::TRASH_SLUG) | ||
| 43 | .where("unique_name NOT LIKE ?", "#{CccConventions::TRASH_SLUG}/%") | ||
| 44 | } | ||
| 45 | |||
| 38 | # Class methods | 46 | # Class methods |
| 39 | 47 | ||
| 40 | # Returns a page for a given node. If no revision is supplied, it returns | 48 | # Returns a page for a given node. If no revision is supplied, it returns |
| @@ -504,7 +512,7 @@ class Node < ApplicationRecord | |||
| 504 | end | 512 | end |
| 505 | 513 | ||
| 506 | def self.drafts_and_autosaves(current_user_id: nil) | 514 | def self.drafts_and_autosaves(current_user_id: nil) |
| 507 | scope = where("draft_id IS NOT NULL OR autosave_id IS NOT NULL") | 515 | scope = where("draft_id IS NOT NULL OR autosave_id IS NOT NULL").not_in_trash |
| 508 | return scope.order("updated_at DESC") unless current_user_id | 516 | return scope.order("updated_at DESC") unless current_user_id |
| 509 | 517 | ||
| 510 | scope.order( | 518 | scope.order( |
