Added highlighting and notices for moderators
- Posts and topics have an added moderation_reports function -- This is so all moderation reports can be loaded in a single query - Those moderation reports are passed into the render functions separately -- This is so the individual comments/posts don't have to be queried
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
@import "../base/000_vars.scss";
|
||||
|
||||
div.comments-for-post {
|
||||
div.moderation-comments-notice {
|
||||
margin: 1em 0;
|
||||
font-weight: bold;
|
||||
color: red;
|
||||
}
|
||||
|
||||
div.hidden-comments-notice {
|
||||
margin: 1em 0;
|
||||
}
|
||||
@@ -13,6 +19,10 @@ div.comments-for-post {
|
||||
background: var(--comment-sticky-background-color);
|
||||
}
|
||||
|
||||
&[data-is-reported="true"] {
|
||||
border: solid red;
|
||||
}
|
||||
|
||||
&[data-is-voted="true"] {
|
||||
.comment-vote-up-link, .comment-vote-down-link {
|
||||
display: none;
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
div.list-of-forum-posts {
|
||||
div.moderation-forums-notice {
|
||||
font-weight: bold;
|
||||
color: red;
|
||||
}
|
||||
|
||||
article.forum-post {
|
||||
&[data-is-reported="true"] {
|
||||
border: solid red;
|
||||
}
|
||||
|
||||
a.voted {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
div#c-users {
|
||||
div#a-show {
|
||||
div.moderation-users-notice {
|
||||
margin: 1em 0;
|
||||
font-weight: bold;
|
||||
color: red;
|
||||
}
|
||||
|
||||
div.box {
|
||||
margin-bottom: 2em;
|
||||
}
|
||||
|
||||
@@ -181,4 +181,9 @@ class ForumTopic < ApplicationRecord
|
||||
def update_orignal_post
|
||||
original_post&.update_columns(:updater_id => CurrentUser.id, :updated_at => Time.now)
|
||||
end
|
||||
|
||||
def moderation_reports
|
||||
posts_with_reports = posts.joins(:moderation_reports).includes(:moderation_reports).distinct
|
||||
posts_with_reports.reduce([]) {|arr,post| arr + post.moderation_reports}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1811,4 +1811,11 @@ class Post < ApplicationRecord
|
||||
|
||||
save
|
||||
end
|
||||
|
||||
def moderation_reports
|
||||
@moderation_reports ||= begin
|
||||
comments_with_reports = comments.joins(:moderation_reports).includes(:moderation_reports).distinct
|
||||
comments_with_reports.reduce([]) {|arr,comment| arr + comment.moderation_reports}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<%= link_to(image_tag(comment.post.preview_file_url), post_path(comment.post)) %>
|
||||
<% end %>
|
||||
</div>
|
||||
<%= render partial: "comments/partials/show/comment", collection: [comment], locals: { context: :index_by_comment, dtext_data: DText.preprocess(@comments.map(&:body)) } %>
|
||||
<%= render partial: "comments/partials/show/comment", collection: [comment], locals: { context: :index_by_comment, dtext_data: DText.preprocess(@comments.map(&:body)), moderation_reports: [] } %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
$("#threshold-comments-notice-for-<%= @post.id %>").hide();
|
||||
|
||||
var current_comment_section = $("div.comments-for-post[data-post-id=<%= @post.id %>] div.list-of-comments");
|
||||
current_comment_section.html("<%= j(render(partial: 'comments/partials/show/comment', collection: @comments, locals: { context: :index_for_post, dtext_data: DText.preprocess(@comments.map(&:body)) })) %>");
|
||||
current_comment_section.html("<%= j(render(partial: 'comments/partials/show/comment', collection: @comments, locals: { context: :index_for_post, dtext_data: DText.preprocess(@comments.map(&:body)), moderation_reports: (CurrentUser.is_moderator? ? @post.moderation_reports : []) })) %>");
|
||||
$(window).trigger("danbooru:index_for_post", [<%= @post.id %>]);
|
||||
|
||||
@@ -3,6 +3,13 @@
|
||||
<%= render "comments/partials/index/header", :post => post %>
|
||||
<% end %>
|
||||
|
||||
<% if CurrentUser.is_moderator? && post.moderation_reports.any? %>
|
||||
<div class="row moderation-comments-notice">
|
||||
<span class="info" id="moderation-comments-notice-for-<%= post.id %>">
|
||||
This post has comments reported for moderation! (<%= post.moderation_reports.count %> <%= (post.moderation_reports.count == 1 ? "report" : "reports") %>)
|
||||
</span>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if post.comments.hidden(CurrentUser.user).any? || (page == :comments && post.comments.size > 6) %>
|
||||
<div class="row hidden-comments-notice">
|
||||
<span class="info" id="threshold-comments-notice-for-<%= post.id %>">
|
||||
@@ -13,7 +20,7 @@
|
||||
|
||||
<div class="list-of-comments list-of-messages">
|
||||
<% if comments.present? %>
|
||||
<%= render partial: "comments/partials/show/comment", collection: comments, locals: { context: :index_by_post, dtext_data: DText.preprocess(comments.map(&:body)) } %>
|
||||
<%= render partial: "comments/partials/show/comment", collection: comments, locals: { context: :index_by_post, dtext_data: DText.preprocess(comments.map(&:body)), moderation_reports: (CurrentUser.is_moderator? ? post.moderation_reports : []) } %>
|
||||
<% elsif post.last_commented_at.present? %>
|
||||
<p>There are no visible comments.</p>
|
||||
<% else %>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<%# locals: comment, context, dtext_data %>
|
||||
<%# locals: comment, context, dtext_data, moderation_reports %>
|
||||
|
||||
<% if CurrentUser.is_moderator? || (params[:search] && params[:search][:is_deleted] =~ /t/) || !comment.is_deleted? %>
|
||||
<a name="comment-<%= comment.id %>"></a>
|
||||
@@ -12,6 +12,9 @@
|
||||
data-is-deleted="<%= comment.is_deleted? %>"
|
||||
data-is-sticky="<%= comment.is_sticky? %>"
|
||||
data-below-threshold="<%= comment.score < CurrentUser.user.comment_threshold %>"
|
||||
<% if CurrentUser.is_moderator? %>
|
||||
data-is-reported="<%= moderation_reports.pluck(:model_id).include?(comment.id) %>"
|
||||
<% end %>
|
||||
data-is-voted="<%= comment.voted_by?(CurrentUser.user) %>">
|
||||
<div class="author">
|
||||
<h4>
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
<% if forum_post.visible?(CurrentUser.user, ActiveModel::Type::Boolean.new.cast(params.dig(:search, :is_deleted))) %>
|
||||
<article class="forum-post message" id="forum_post_<%= forum_post.id %>" data-forum-post-id="<%= forum_post.id %>" data-creator="<%= forum_post.creator.name %>">
|
||||
<article class="forum-post message" id="forum_post_<%= forum_post.id %>"
|
||||
data-forum-post-id="<%= forum_post.id %>"
|
||||
<% if CurrentUser.is_moderator? %>
|
||||
data-is-reported="<%= moderation_reports.pluck(:model_id).include?(forum_post.id) %>"
|
||||
<% end %>
|
||||
data-creator="<%= forum_post.creator.name %>">
|
||||
<div class="author">
|
||||
<h4>
|
||||
<%= link_to_user forum_post.creator %>
|
||||
|
||||
@@ -1,9 +1,18 @@
|
||||
<%- # forum_post %>
|
||||
<%- # original_forum_post_id %>
|
||||
<%- # dtext_data %>
|
||||
<%- # moderation_reports %>
|
||||
|
||||
<div class="list-of-forum-posts list-of-messages">
|
||||
<% if CurrentUser.is_moderator? && moderation_reports.any? %>
|
||||
<div class="row moderation-forums-notice">
|
||||
<span class="info" id="moderation-forums-notice-for-topic">
|
||||
This topic has forum posts reported for moderation! (<%= moderation_reports.count %> <%= (moderation_reports.count == 1 ? "report" : "reports") %>)
|
||||
</span>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% forum_posts.each do |forum_post| %>
|
||||
<%= render "forum_posts/forum_post", forum_post: forum_post, original_forum_post_id: original_forum_post_id, dtext_data: dtext_data %>
|
||||
<%= render "forum_posts/forum_post", forum_post: forum_post, original_forum_post_id: original_forum_post_id, dtext_data: dtext_data, moderation_reports: moderation_reports %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= render "forum_posts/listing", forum_posts: @forum_posts, original_forum_post_id: @forum_topic.original_post.id, dtext_data: DText.preprocess(@forum_posts.map(&:body)) %>
|
||||
<%= render "forum_posts/listing", forum_posts: @forum_posts, original_forum_post_id: @forum_topic.original_post.id, dtext_data: DText.preprocess(@forum_posts.map(&:body)), moderation_reports: (CurrentUser.is_moderator? ? @forum_topic.moderation_reports : []) %>
|
||||
|
||||
<% if CurrentUser.is_member? %>
|
||||
<% if CurrentUser.is_moderator? || !@forum_topic.is_locked? %>
|
||||
|
||||
@@ -2,6 +2,14 @@
|
||||
<div id="a-show">
|
||||
<h1><%= link_to_user @user %></h1>
|
||||
|
||||
<% if !@user.is_moderator? && CurrentUser.is_moderator? && @user.moderation_reports.any? %>
|
||||
<div class="moderation-users-notice">
|
||||
<span class="info" id="moderation-users-notice-for-<%= @user.id %>">
|
||||
This user has been reported for moderation! (<%= @user.moderation_reports.count %> <%= (@user.moderation_reports.count == 1 ? "report" : "reports") %>)
|
||||
</span>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= render "statistics", presenter: @user.presenter, user: @user %>
|
||||
|
||||
<%= render "posts/partials/common/inline_blacklist" %>
|
||||
|
||||
Reference in New Issue
Block a user