Add a listing page for post disapprovals (accessible to approvers only)

This commit is contained in:
Albert Yi 2019-01-22 17:04:52 -08:00
parent a5943d2c3a
commit 33063a72de
7 changed files with 41 additions and 7 deletions

View File

@ -11,6 +11,10 @@ module Moderator
respond_with(@post_disapproval)
end
def index
@post_disapprovals = PostDisapproval.paginate(params[:page])
end
private
def post_disapproval_params

View File

@ -0,0 +1,30 @@
<div id="c-moderator-post-disapprovals">
<div id="a-index">
<h1>Disapprovals</h1>
<table class="striped" width="100%">
<thead>
<tr>
<th>Post</th>
<th>Reason</th>
<th>Creator</th>
</tr>
</thead>
<tbody>
<% @post_disapprovals.each do |post_disapproval| %>
<tr>
<td><%= link_to post_disapproval.post_id, post_path(post_disapproval.post_id) %></td>
<td><%= post_disapproval.reason %>: <%= post_disapproval.message %></td>
<td><%= post_disapproval.user.name %></td>
</tr>
<% end %>
</tbody>
</table>
<%= numbered_paginator(@post_disapprovals) %>
</div>
</div>
<% content_for(:page_title) do %>
Post Disapprovals - <%= Danbooru.config.app_name %>
<% end %>

View File

@ -1,7 +1,7 @@
<div class="quick-mod">
<%= link_to_if post.is_approvable?, "Approve", moderator_post_approval_path(post_id: post.id), method: :post, remote: true, class: "approve-link btn" %> |
<%= link_to "Breaks Rules", moderator_post_disapproval_path(post_disapproval: { post_id: post.id, reason: "breaks_rules" }), method: :post, remote: true, class: "disapprove-link btn" %> |
<%= link_to "Poor Quality", moderator_post_disapproval_path(post_disapproval: { post_id: post.id, reason: "poor_quality" }), method: :post, remote: true, class: "disapprove-link btn" %> |
<%= link_to "No Interest", moderator_post_disapproval_path(post_disapproval: { post_id: post.id, reason: "disinterest" }), method: :post, remote: true, class: "disapprove-link btn" %> |
<%= link_to "Breaks Rules", moderator_post_disapprovals_path(post_disapproval: { post_id: post.id, reason: "breaks_rules" }), method: :post, remote: true, class: "disapprove-link btn" %> |
<%= link_to "Poor Quality", moderator_post_disapprovals_path(post_disapproval: { post_id: post.id, reason: "poor_quality" }), method: :post, remote: true, class: "disapprove-link btn" %> |
<%= link_to "No Interest", moderator_post_disapprovals_path(post_disapproval: { post_id: post.id, reason: "disinterest" }), method: :post, remote: true, class: "disapprove-link btn" %> |
<%= link_to "Detailed Rejection", "#", "data-post-id" => post.id, class: "detailed-rejection-link btn" %>
</div>

View File

@ -1,7 +1,7 @@
<div id="detailed-rejection-dialog" title="Detailed Rejection" style="display: none;">
<p>You can supply a short message to the uploader explaining why you rejected this upload.</p>
<%= simple_form_for(PostDisapproval.new, url: moderator_post_disapproval_path, remote: true, id: "detailed-rejection-form") do |f| %>
<%= simple_form_for(PostDisapproval.new, url: moderator_post_disapprovals_path, remote: true, id: "detailed-rejection-form") do |f| %>
<%= f.hidden_field :post_id, value: "x" %>
<%= f.input :reason, collection: [["Breaks Rules", "breaks_rules"], ["Poor Quality", "poor_quality"], ["No interest", "disinterest"]] %>
<%= f.input :message, as: :string %>

View File

@ -42,7 +42,7 @@
<% if post.is_approvable? && !post.is_deleted? %>
<li><%= link_to "Approve", moderator_post_approval_path(:post_id => post.id), :remote => true, :method => :post, :id => "approve", :"data-shortcut" => "shift+o", :"data-confirm" => "Are you sure you want to approve this post?" %></li>
<li><%= link_to "Hide from queue", moderator_post_disapproval_path(post_disapproval: { post_id: post.id, reason: "disinterest" }), remote: true, method: :post, id: "disapprove" %></li>
<li><%= link_to "Hide from queue", moderator_post_disapprovals_path(post_disapproval: { post_id: post.id, reason: "disinterest" }), remote: true, method: :post, id: "disapprove" %></li>
<% end %>
<% if post.is_banned? %>

View File

@ -22,7 +22,7 @@ Rails.application.routes.draw do
end
end
resource :approval, :only => [:create]
resource :disapproval, :only => [:create]
resources :disapprovals, :only => [:create, :index]
resources :posts, :only => [:delete, :undelete, :expunge, :confirm_delete] do
member do
get :confirm_delete

View File

@ -14,7 +14,7 @@ module Moderator
context "create action" do
should "render" do
assert_difference("PostDisapproval.count", 1) do
post_auth moderator_post_disapproval_path, @admin, params: { post_disapproval: { post_id: @post.id, reason: "breaks_rules" }, format: "js" }
post_auth moderator_post_disapprovals_path, @admin, params: { post_disapproval: { post_id: @post.id, reason: "breaks_rules" }, format: "js" }
end
assert_response :success
end