models: add deletable concern.

This commit is contained in:
evazion
2020-03-06 17:06:29 -06:00
parent 32bad825e1
commit 5bc0ab446b
13 changed files with 30 additions and 37 deletions

View File

@@ -9,6 +9,8 @@ class Post < ApplicationRecord
# Tags to copy when copying notes.
NOTE_COPY_TAGS = %w[translated partially_translated check_translation translation_request reverse_translation]
deletable
before_validation :merge_old_changes
before_validation :normalize_tags
before_validation :strip_source
@@ -60,9 +62,7 @@ class Post < ApplicationRecord
scope :flagged, -> { where(is_flagged: true) }
scope :pending_or_flagged, -> { pending.or(flagged) }
scope :undeleted, -> { where(is_deleted: false) }
scope :unflagged, -> { where(is_flagged: false) }
scope :deleted, -> { where(is_deleted: true) }
scope :has_notes, -> { where.not(last_noted_at: nil) }
scope :for_user, ->(user_id) { where(uploader_id: user_id) }