modreports: remove dead code.
This commit is contained in:
@@ -1,11 +1,5 @@
|
|||||||
div#c-users {
|
div#c-users {
|
||||||
div#a-show {
|
div#a-show {
|
||||||
div.moderation-users-notice {
|
|
||||||
margin: 1em 0;
|
|
||||||
font-weight: bold;
|
|
||||||
color: var(--moderation-report-text-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
div.box {
|
div.box {
|
||||||
margin-bottom: 2em;
|
margin-bottom: 2em;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,26 +1,23 @@
|
|||||||
class ModerationReport < ApplicationRecord
|
class ModerationReport < ApplicationRecord
|
||||||
|
MODEL_TYPES = %w[Dmail Comment ForumPost]
|
||||||
|
|
||||||
belongs_to :model, polymorphic: true
|
belongs_to :model, polymorphic: true
|
||||||
belongs_to :creator, class_name: "User"
|
belongs_to :creator, class_name: "User"
|
||||||
|
|
||||||
validates :reason, presence: true
|
validates :reason, presence: true
|
||||||
validates :model_type, inclusion: { in: %w[Comment Dmail ForumPost User] }
|
validates :model_type, inclusion: { in: MODEL_TYPES }
|
||||||
validates :creator, uniqueness: { scope: [:model_type, :model_id], message: "have already reported this message." }
|
validates :creator, uniqueness: { scope: [:model_type, :model_id], message: "have already reported this message." }
|
||||||
|
|
||||||
after_create :create_forum_post!
|
after_create :create_forum_post!
|
||||||
after_create :autoban_reported_user
|
after_create :autoban_reported_user
|
||||||
|
|
||||||
scope :user, -> { where(model_type: "User") }
|
|
||||||
scope :dmail, -> { where(model_type: "Dmail") }
|
scope :dmail, -> { where(model_type: "Dmail") }
|
||||||
scope :comment, -> { where(model_type: "Comment") }
|
scope :comment, -> { where(model_type: "Comment") }
|
||||||
scope :forum_post, -> { where(model_type: "ForumPost") }
|
scope :forum_post, -> { where(model_type: "ForumPost") }
|
||||||
scope :recent, -> { where("moderation_reports.created_at >= ?", 1.week.ago) }
|
scope :recent, -> { where("moderation_reports.created_at >= ?", 1.week.ago) }
|
||||||
|
|
||||||
def self.enabled?
|
|
||||||
!Rails.env.production?
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.model_types
|
def self.model_types
|
||||||
%w[User Dmail Comment ForumPost]
|
MODEL_TYPES
|
||||||
end
|
end
|
||||||
|
|
||||||
def forum_topic_title
|
def forum_topic_title
|
||||||
|
|||||||
@@ -19,10 +19,6 @@ class UserPolicy < ApplicationPolicy
|
|||||||
!user.is_anonymous?
|
!user.is_anonymous?
|
||||||
end
|
end
|
||||||
|
|
||||||
def reportable?
|
|
||||||
false
|
|
||||||
end
|
|
||||||
|
|
||||||
def fix_counts?
|
def fix_counts?
|
||||||
!user.is_anonymous?
|
!user.is_anonymous?
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,9 +3,7 @@
|
|||||||
<h1>Moderation reports</h1>
|
<h1>Moderation reports</h1>
|
||||||
<%= table_for @moderation_reports, width: "100%" do |t| %>
|
<%= table_for @moderation_reports, width: "100%" do |t| %>
|
||||||
<% t.column "Reported", width: "10%" do |report| %>
|
<% t.column "Reported", width: "10%" do |report| %>
|
||||||
<% if report.model_type == "User" %>
|
<% if report.model_type == "Dmail" %>
|
||||||
<%= link_to_user report.model %>
|
|
||||||
<% elsif report.model_type == "Dmail" %>
|
|
||||||
<%= link_to report.model.dtext_shortlink, dmail_path(report.model, key: report.model.key) %>
|
<%= link_to report.model.dtext_shortlink, dmail_path(report.model, key: report.model.key) %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= link_to report.model.dtext_shortlink, report.model %>
|
<%= link_to report.model.dtext_shortlink, report.model %>
|
||||||
|
|||||||
@@ -21,9 +21,6 @@
|
|||||||
<% if !@user.is_platinum? %>
|
<% if !@user.is_platinum? %>
|
||||||
<%= subnav_link_to "Gift upgrade", new_user_upgrade_path(:user_id => @user.id) %>
|
<%= subnav_link_to "Gift upgrade", new_user_upgrade_path(:user_id => @user.id) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if policy(@user).reportable? %>
|
|
||||||
<%= subnav_link_to "Report user", new_moderation_report_path(moderation_report: { model_type: "User", model_id: @user.id }), remote: true %>
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if policy(CurrentUser.user).promote? %>
|
<% if policy(CurrentUser.user).promote? %>
|
||||||
|
|||||||
@@ -5,14 +5,6 @@
|
|||||||
<div id="a-show">
|
<div id="a-show">
|
||||||
<h1><%= link_to_user @user %></h1>
|
<h1><%= link_to_user @user %></h1>
|
||||||
|
|
||||||
<% if @user.moderation_reports.visible(CurrentUser.user).recent.present? %>
|
|
||||||
<div class="moderation-users-notice">
|
|
||||||
<span class="info" id="moderation-users-notice-for-<%= @user.id %>">
|
|
||||||
This user has been reported for moderation! (<%= pluralize(@user.moderation_reports.visible(CurrentUser.user).recent.length, "report") %>)
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<%= render "statistics", presenter: @user.presenter, user: @user %>
|
<%= render "statistics", presenter: @user.presenter, user: @user %>
|
||||||
|
|
||||||
<%= render "posts/partials/common/inline_blacklist" %>
|
<%= render "posts/partials/common/inline_blacklist" %>
|
||||||
|
|||||||
Reference in New Issue
Block a user