views: refactor post flag and appeal reasons.
* Prefer partials over helpers. * Add css classes to flag/appeal reason lists. * Wrap dtext in span.prose container.
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
module Moderator
|
module Moderator
|
||||||
class DashboardsController < ApplicationController
|
class DashboardsController < ApplicationController
|
||||||
before_action :member_only
|
before_action :member_only
|
||||||
helper :post_flags, :post_appeals
|
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@dashboard = Moderator::Dashboard::Report.new(**search_params.to_h.symbolize_keys)
|
@dashboard = Moderator::Dashboard::Report.new(**search_params.to_h.symbolize_keys)
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
module PostAppealsHelper
|
|
||||||
def post_appeal_reasons(post)
|
|
||||||
html = []
|
|
||||||
html << '<ul>'
|
|
||||||
|
|
||||||
post.appeals.each do |appeal|
|
|
||||||
reason = format_text(appeal.reason, inline: true)
|
|
||||||
user = link_to_user(appeal.creator)
|
|
||||||
if CurrentUser.is_moderator?
|
|
||||||
ip = "(#{link_to_ip(appeal.creator_ip_addr)})"
|
|
||||||
else
|
|
||||||
ip = ""
|
|
||||||
end
|
|
||||||
time = time_ago_in_words_tagged(appeal.created_at)
|
|
||||||
|
|
||||||
html << "<li>#{reason} - #{user} #{ip} #{time}</li>"
|
|
||||||
end
|
|
||||||
|
|
||||||
html << '</ul>'
|
|
||||||
html.join("\n").html_safe
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
module PostFlagsHelper
|
|
||||||
def post_flag_reasons(post)
|
|
||||||
html = []
|
|
||||||
html << '<ul>'
|
|
||||||
|
|
||||||
post.flags.each do |flag|
|
|
||||||
html << '<li>'
|
|
||||||
html << format_text(flag.reason, inline: true)
|
|
||||||
|
|
||||||
if CurrentUser.can_view_flagger_on_post?(flag)
|
|
||||||
html << " - #{link_to_user(flag.creator)}"
|
|
||||||
if CurrentUser.is_moderator?
|
|
||||||
html << " (#{link_to_ip(flag.creator_ip_addr)})"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
html << ' - ' + time_ago_in_words_tagged(flag.created_at)
|
|
||||||
|
|
||||||
if flag.is_resolved?
|
|
||||||
html << ' <span class="resolved">RESOLVED</span>'
|
|
||||||
end
|
|
||||||
|
|
||||||
html << '</li>'
|
|
||||||
end
|
|
||||||
|
|
||||||
html << '</ul>'
|
|
||||||
html.join("\n").html_safe
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -14,8 +14,8 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td><%= PostPresenter.preview(post, show_deleted: true) %></td>
|
<td><%= PostPresenter.preview(post, show_deleted: true) %></td>
|
||||||
<td><%= mod_link_to_user post.uploader, :negative %></td>
|
<td><%= mod_link_to_user post.uploader, :negative %></td>
|
||||||
<td><%= post_flag_reasons(post) %></td>
|
<td><%= render "post_flags/reasons", flags: post.flags %></td>
|
||||||
<td><%= post_appeal_reasons(post) %></td>
|
<td><%= render "post_appeals/reasons", appeals: post.appeals %></td>
|
||||||
<td><%= post.score %></td>
|
<td><%= post.score %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -19,10 +19,10 @@
|
|||||||
</li>
|
</li>
|
||||||
<li><strong>Uploader</strong>: <%= link_to_user(post.uploader) %> <%= time_ago_in_words_tagged(post.created_at) %></li>
|
<li><strong>Uploader</strong>: <%= link_to_user(post.uploader) %> <%= time_ago_in_words_tagged(post.created_at) %></li>
|
||||||
<% if post.is_flagged? %>
|
<% if post.is_flagged? %>
|
||||||
<li><strong>Flagged</strong>: <%= post_flag_reasons(post) %></li>
|
<li><strong>Flagged</strong>: <%= render "post_flags/reasons", flags: post.flags %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if (post.is_flagged? || post.is_deleted?) && post.appeals.any? %>
|
<% if (post.is_flagged? || post.is_deleted?) && post.appeals.any? %>
|
||||||
<li><strong>Appeals</strong>: <%= post_appeal_reasons(post) %></li>
|
<li><strong>Appeals</strong>: <%= render "post_appeals/reasons", appeals: post.appeals %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<li>
|
<li>
|
||||||
<strong>Hidden</strong>: <%= render "post_disapprovals/compact_counts", :disapprovals => post.disapprovals, :post => post %>
|
<strong>Hidden</strong>: <%= render "post_disapprovals/compact_counts", :disapprovals => post.disapprovals, :post => post %>
|
||||||
|
|||||||
15
app/views/post_appeals/_reasons.html.erb
Normal file
15
app/views/post_appeals/_reasons.html.erb
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<ul class="post-appeal-reasons">
|
||||||
|
<% appeals.each do |appeal| %>
|
||||||
|
<li class="post-appeal-reason">
|
||||||
|
<span class="prose"><%= format_text(appeal.reason, inline: true) %></span>
|
||||||
|
|
||||||
|
- <%= link_to_user(appeal.creator) %>
|
||||||
|
|
||||||
|
<% if CurrentUser.is_moderator? %>
|
||||||
|
(<%= link_to_ip(appeal.creator_ip_addr) %>)
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
- <%= time_ago_in_words_tagged(appeal.created_at) %>
|
||||||
|
</li>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
21
app/views/post_flags/_reasons.html.erb
Normal file
21
app/views/post_flags/_reasons.html.erb
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<ul class="post-flag-reasons">
|
||||||
|
<% flags.each do |flag| %>
|
||||||
|
<li class="post-flag-reason">
|
||||||
|
<span class="prose"><%= format_text(flag.reason, inline: true) %></span>
|
||||||
|
|
||||||
|
<% if CurrentUser.can_view_flagger_on_post?(flag) %>
|
||||||
|
- <%= link_to_user(flag.creator) %>
|
||||||
|
|
||||||
|
<% if CurrentUser.is_moderator? %>
|
||||||
|
(<%= link_to_ip(flag.creator_ip_addr) %>)
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
- <%= time_ago_in_words_tagged(flag.created_at) %>
|
||||||
|
|
||||||
|
<% if flag.is_resolved? %>
|
||||||
|
<span class="resolved">RESOLVED</span>
|
||||||
|
<% end %>
|
||||||
|
</li>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
<div class="post-notice post-notice-flagged">
|
<div class="post-notice post-notice-flagged">
|
||||||
<p>This post was flagged for review (<%= link_to "learn more", wiki_pages_path(:title => "howto:flag") %>): </p>
|
<p>This post was flagged for review (<%= link_to "learn more", wiki_pages_path(:title => "howto:flag") %>): </p>
|
||||||
|
|
||||||
<%= post_flag_reasons(post) %>
|
<%= render "post_flags/reasons", flags: post.flags %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
<div class="post-notice post-notice-deleted">
|
<div class="post-notice post-notice-deleted">
|
||||||
<% if post.flags.any? %>
|
<% if post.flags.any? %>
|
||||||
<p>This post was deleted for the following reasons: </p>
|
<p>This post was deleted for the following reasons: </p>
|
||||||
<%= post_flag_reasons(post) %>
|
<%= render "post_flags/reasons", flags: post.flags %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<p>This post was deleted</p>
|
<p>This post was deleted</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
<% if (post.is_flagged? || post.is_deleted?) && post.appeals.any? %>
|
<% if (post.is_flagged? || post.is_deleted?) && post.appeals.any? %>
|
||||||
<div class="post-notice post-notice-appealed">
|
<div class="post-notice post-notice-appealed">
|
||||||
<p>This post was appealed:</p>
|
<p>This post was appealed:</p>
|
||||||
<%= post_appeal_reasons(post) %>
|
<%= render "post_appeals/reasons", appeals: post.appeals %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user