Exempt deletions from dupe flag checking

This commit is contained in:
Toks
2014-10-31 20:01:42 -04:00
parent e6c4cd6c6d
commit 095d02414c
4 changed files with 13 additions and 5 deletions

View File

@@ -218,12 +218,12 @@ class Post < ActiveRecord::Base
!is_status_locked? && (is_pending? || is_flagged? || is_deleted?) && approver_id != CurrentUser.id
end
def flag!(reason)
def flag!(reason, options = {})
if is_status_locked?
raise PostFlag::Error.new("Post is locked and cannot be flagged")
end
flag = flags.create(:reason => reason, :is_resolved => false)
flag = flags.create(:reason => reason, :is_resolved => false, :is_deletion => options[:is_deletion])
if flag.errors.any?
raise PostFlag::Error.new(flag.errors.full_messages.join("; "))