Fix a case when a staff user views a topic with a deleted post by a nuked user; might be a temporary solution until we decide what to do with nuked records

This commit is contained in:
Neil Lalonde
2013-07-10 16:52:34 -04:00
parent 91dc0b9ef1
commit 8814f9ed05
8 changed files with 17 additions and 2 deletions

View File

@@ -3,7 +3,7 @@
# Use the AdminLogger class to log records to this table.
class AdminLog < ActiveRecord::Base
belongs_to :admin, class_name: 'User'
belongs_to :target_user, class_name: 'User' # can be nil
belongs_to :target_user, class_name: 'User' # can be nil, or return nil if user record was nuked
validates_presence_of :admin_id
validates_presence_of :action

View File

@@ -45,6 +45,7 @@ class Post < ActiveRecord::Base
scope :public_posts, -> { joins(:topic).where('topics.archetype <> ?', Archetype.private_message) }
scope :private_posts, -> { joins(:topic).where('topics.archetype = ?', Archetype.private_message) }
scope :with_topic_subtype, ->(subtype) { joins(:topic).where('topics.subtype = ?', subtype) }
scope :without_nuked_users, -> { where(nuked_user: false) }
def self.hidden_reasons
@hidden_reasons ||= Enum.new(:flag_threshold_reached, :flag_threshold_reached_again, :new_user_spam_threshold_reached)