Made recommended changes to moderator reports (see #4267)
This commit is contained in:
@@ -184,6 +184,6 @@ class ForumTopic < ApplicationRecord
|
||||
end
|
||||
|
||||
def viewable_moderation_reports
|
||||
CurrentUser.is_moderator? ? moderation_reports : []
|
||||
CurrentUser.is_moderator? ? moderation_reports.recent : []
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,9 +2,13 @@ class ModerationReport < ApplicationRecord
|
||||
belongs_to :model, polymorphic: true
|
||||
belongs_to_creator
|
||||
|
||||
validates :reason, presence: true
|
||||
after_create :create_forum_post!
|
||||
|
||||
scope :user, -> { where(model_type: "User") }
|
||||
scope :comment, -> { where(model_type: "Comment") }
|
||||
scope :forum_post, -> { where(model_type: "ForumPost") }
|
||||
scope :recent, -> { where("moderation_reports.created_at >= ?", 1.week.ago) }
|
||||
|
||||
def forum_topic_title
|
||||
"Reports requiring moderation"
|
||||
@@ -54,8 +58,4 @@ class ModerationReport < ApplicationRecord
|
||||
|
||||
q.apply_default_order(params)
|
||||
end
|
||||
|
||||
def self.prune!
|
||||
where("created_at < ?", 1.week.ago).delete_all
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1814,6 +1814,6 @@ class Post < ApplicationRecord
|
||||
end
|
||||
|
||||
def viewable_moderation_reports
|
||||
CurrentUser.is_moderator? ? moderation_reports : []
|
||||
CurrentUser.is_moderator? ? moderation_reports.recent : []
|
||||
end
|
||||
end
|
||||
|
||||
@@ -814,6 +814,6 @@ class User < ApplicationRecord
|
||||
end
|
||||
|
||||
def viewable_moderation_reports
|
||||
!is_moderator? && CurrentUser.is_moderator? ? moderation_reports : []
|
||||
CurrentUser.is_moderator? ? moderation_reports.recent : []
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user