Create the ability to send reports to moderators

- Limited to Builders+
-- Moderator+ can also use as they may be too busy ATM
- Only on users, comments, and forum posts
- Multiple reports can be generated per instance
- Primarily posts to a moderator-only topic for viewability
- Secondarily has a table for searchability
-- Viewable only by moderators
This commit is contained in:
BrokenEagle
2020-01-18 05:34:46 +00:00
parent 4a7322b197
commit 4cef0e45c2
17 changed files with 255 additions and 0 deletions

View File

@@ -53,6 +53,9 @@
<li class="comment-unvote-link">
<%= link_to "Unvote", comment_comment_votes_path(comment_id: comment.id), method: :delete, remote: true %>
</li>
<% if comment.reportable_by?(CurrentUser.user) %>
<li><%= link_to "Report comment", new_moderation_report_path(moderation_report: { model_type: "Comment", model_id: comment.id }), remote: true %></li>
<% end %>
</menu>
<% if comment.editable_by?(CurrentUser.user) %>
<%= render "comments/form", comment: comment, hidden: true %>

View File

@@ -32,6 +32,9 @@
<li><%= link_to "Edit", edit_forum_post_path(forum_post.id), :id => "edit_forum_post_link_#{forum_post.id}", :class => "edit_forum_post_link" %></li>
<% end %>
<% end %>
<% if forum_post.reportable_by?(CurrentUser.user) %>
<li><%= link_to "Report forum", new_moderation_report_path(moderation_report: { model_type: "ForumPost", model_id: forum_post.id }), remote: true %></li>
<% end %>
<% if forum_post.votable? %>
<ul class="votes" id="forum-post-votes-for-<%= forum_post.id %>">
<%= render "forum_post_votes/list", votes: forum_post.votes, forum_post: forum_post %>

View File

@@ -0,0 +1,14 @@
<div class="report-dialog-body">
<div class="prose">
<%= format_text(WikiPage.titled(Danbooru.config.report_notice_wiki_page).first.try(&:body)) %>
</div>
<%# XXX dtext_field expects there to be a `moderation_report` instance variable. %>
<% @moderation_report = moderation_report %>
<%= edit_form_for(@moderation_report, format: :js, remote: true) do |f| %>
<%= f.hidden_field :model_type %>
<%= f.hidden_field :model_id %>
<%= dtext_field "moderation_report", "reason", preview_id: "dtext-preview-for-moderation-report", type: "string" %>
<%= dtext_preview_button "moderation_report", "reason", preview_id: "dtext-preview-for-moderation-report" %>
<% end %>
</div>

View File

@@ -0,0 +1 @@
Danbooru.notice("Report submitted.");

View File

@@ -0,0 +1,27 @@
<div id="c-moderation-reports">
<div id="a-index">
<h1>Moderation reports</h1>
<%= table_for @moderation_reports, width: "100%" do |t| %>
<% t.column "Reported", width: "10%" do |report| %>
<% if report.model_type == "User" %>
<%= link_to_user report.model %>
<% elsif report.model_type == "Comment" %>
<%= link_to "comment ##{report.model_id}", comment_path(report.model_id) %>
<% elsif report.model_type == "ForumPost" %>
<%= link_to "forum ##{report.model_id}", forum_post_path(report.model_id) %>
<% end %>
<% end %>
<% t.column "Reason" do |report| %>
<span class="prose">
<%= format_text report.reason, inline: true %>
</span>
<% end %>
<% t.column "Creator", width: "10%" do |report| %>
<%= compact_time report.created_at %>
<br> by <%= link_to_user report.creator %>
<% end %>
<% end %>
<%= numbered_paginator(@moderation_reports) %>
</div>
</div>

View File

@@ -0,0 +1 @@
Danbooru.Utility.dialog("Send report", "<%= j render "moderation_reports/new", moderation_report: @moderation_report %>");

View File

@@ -155,6 +155,7 @@
<% end %>
<% if CurrentUser.is_moderator? %>
<li><%= link_to("Moderation Reports", moderation_reports_path) %></li>
<li><%= link_to("IP Addresses", ip_addresses_path) %></li>
<li><%= link_to("IP Bans", ip_bans_path) %></li>
<% end %>

View File

@@ -22,6 +22,9 @@
<% if !@user.is_platinum? %>
<%= subnav_link_to "Gift upgrade", new_user_upgrade_path(:user_id => @user.id) %>
<% end %>
<% if @user.reportable_by?(CurrentUser.user) %>
<%= subnav_link_to "Report user", new_moderation_report_path(moderation_report: { model_type: "User", model_id: @user.id }), remote: true %>
<% end %>
<% end %>
<% if CurrentUser.user.is_moderator? %>