controllers: move /moderator/post/disapprovals to /post_disapprovals.
This commit is contained in:
@@ -1,32 +0,0 @@
|
||||
module Moderator
|
||||
module Post
|
||||
class DisapprovalsController < ApplicationController
|
||||
before_action :approver_only
|
||||
skip_before_action :api_check
|
||||
respond_to :js, :html, :json, :xml
|
||||
|
||||
def create
|
||||
cookies.permanent[:moderated] = Time.now.to_i
|
||||
@post_disapproval = PostDisapproval.create(post_disapproval_params)
|
||||
respond_with(@post_disapproval, location: moderator_post_disapprovals_path)
|
||||
end
|
||||
|
||||
def index
|
||||
@post_disapprovals = PostDisapproval.paginated_search(params)
|
||||
@post_disapprovals = @post_disapprovals.includes(:user) if request.format.html?
|
||||
|
||||
respond_with(@post_disapprovals)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def model_name
|
||||
"PostDisapproval"
|
||||
end
|
||||
|
||||
def post_disapproval_params
|
||||
params.require(:post_disapproval).permit(%i[post_id reason message])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
24
app/controllers/post_disapprovals_controller.rb
Normal file
24
app/controllers/post_disapprovals_controller.rb
Normal file
@@ -0,0 +1,24 @@
|
||||
class PostDisapprovalsController < ApplicationController
|
||||
before_action :approver_only
|
||||
skip_before_action :api_check
|
||||
respond_to :js, :html, :json, :xml
|
||||
|
||||
def create
|
||||
cookies.permanent[:moderated] = Time.now.to_i
|
||||
@post_disapproval = PostDisapproval.create(post_disapproval_params)
|
||||
respond_with(@post_disapproval)
|
||||
end
|
||||
|
||||
def index
|
||||
@post_disapprovals = PostDisapproval.paginated_search(params)
|
||||
@post_disapprovals = @post_disapprovals.includes(:user) if request.format.html?
|
||||
|
||||
respond_with(@post_disapprovals)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def post_disapproval_params
|
||||
params.require(:post_disapproval).permit(%i[post_id reason message])
|
||||
end
|
||||
end
|
||||
@@ -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_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 "Breaks Rules", post_disapprovals_path(post_disapproval: { post_id: post.id, reason: "breaks_rules" }), method: :post, remote: true, class: "disapprove-link btn" %> |
|
||||
<%= link_to "Poor Quality", post_disapprovals_path(post_disapproval: { post_id: post.id, reason: "poor_quality" }), method: :post, remote: true, class: "disapprove-link btn" %> |
|
||||
<%= link_to "No Interest", 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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
<%= edit_form_for(PostDisapproval.new, url: moderator_post_disapprovals_path, remote: true, html: { id: "detailed-rejection-form" }) do |f| %>
|
||||
<%= edit_form_for(PostDisapproval.new, url: post_disapprovals_path, remote: true, html: { 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 %>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<div id="c-moderator-post-disapprovals">
|
||||
<div id="c-post-disapprovals">
|
||||
<div id="a-index">
|
||||
<h1>Disapprovals</h1>
|
||||
|
||||
<%= search_form_for(moderator_post_disapprovals_path) do |f| %>
|
||||
<%= search_form_for(post_disapprovals_path) do |f| %>
|
||||
<%= f.input :user_name, label: "Creator", input_html: { value: params[:search][:user_name] } %>
|
||||
<%= f.input :post_id, label: "Post ID", input_html: { value: params[:search][:post_id] } %>
|
||||
<%= f.input :post_tags_match, label: "Tags", input_html: { value: params[:search][:post_tags_match], data: { autocomplete: "tag-query" } } %>
|
||||
@@ -16,7 +16,7 @@
|
||||
<%= table_for @post_disapprovals, {class: "striped autofit", width: "100%"} do |t| %>
|
||||
<% t.column "Post" do |post_disapproval| %>
|
||||
<%= link_to "post ##{post_disapproval.post_id}", post_path(post_disapproval.post_id) %>
|
||||
<%= link_to "»", moderator_post_disapprovals_path(search: params[:search].merge(post_id: post_disapproval.post_id)) %>
|
||||
<%= link_to "»", post_disapprovals_path(search: params[:search].merge(post_id: post_disapproval.post_id)) %>
|
||||
<% end %>
|
||||
<% t.column "Message", td: {class: "col-expand"} do |post_disapproval| %>
|
||||
<div class="prose">
|
||||
@@ -24,11 +24,11 @@
|
||||
</div>
|
||||
<% end %>
|
||||
<% t.column "Reason" do |post_disapproval| %>
|
||||
<%= link_to post_disapproval.reason.humanize, moderator_post_disapprovals_path(search: params[:search].merge(reason: post_disapproval.reason)) %>
|
||||
<%= link_to post_disapproval.reason.humanize, post_disapprovals_path(search: params[:search].merge(reason: post_disapproval.reason)) %>
|
||||
<% end %>
|
||||
<% t.column "Created" do |post_disapproval| %>
|
||||
<%= link_to_user post_disapproval.user %>
|
||||
<%= link_to "»", moderator_post_disapprovals_path(search: params[:search].merge(creator_name: post_disapproval.user&.name)) %>
|
||||
<%= link_to "»", post_disapprovals_path(search: params[:search].merge(creator_name: post_disapproval.user&.name)) %>
|
||||
<p>
|
||||
<%= compact_time(post_disapproval.updated_at) %>
|
||||
</p>
|
||||
@@ -52,7 +52,7 @@
|
||||
|
||||
<% if post.is_approvable? && !post.is_deleted? %>
|
||||
<li id="post-option-approve"><%= 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 id="post-option-disapprove"><%= link_to "Hide from queue", moderator_post_disapprovals_path(post_disapproval: { post_id: post.id, reason: "disinterest" }), remote: true, method: :post, id: "disapprove" %></li>
|
||||
<li id="post-option-disapprove"><%= link_to "Hide from queue", post_disapprovals_path(post_disapproval: { post_id: post.id, reason: "disinterest" }), remote: true, method: :post, id: "disapprove" %></li>
|
||||
<% end %>
|
||||
|
||||
<% if post.is_banned? %>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<li><%= link_to("Changes", post_versions_path) %></li>
|
||||
<li><%= link_to("Approvals", post_approvals_path) %></li>
|
||||
<% if CurrentUser.is_approver? %>
|
||||
<li><%= link_to("Disapprovals", moderator_post_disapprovals_path) %></li>
|
||||
<li><%= link_to("Disapprovals", post_disapprovals_path) %></li>
|
||||
<% end %>
|
||||
<li><%= link_to("Appeals", post_appeals_path) %></li>
|
||||
<li><%= link_to("Flags", post_flags_path) %></li>
|
||||
|
||||
@@ -20,7 +20,6 @@ Rails.application.routes.draw do
|
||||
end
|
||||
end
|
||||
resource :approval, :only => [:create]
|
||||
resources :disapprovals, :only => [:create, :index]
|
||||
resources :posts, :only => [:delete, :undelete, :expunge, :confirm_delete] do
|
||||
member do
|
||||
get :confirm_delete
|
||||
@@ -206,6 +205,7 @@ Rails.application.routes.draw do
|
||||
resources :post_appeals
|
||||
resources :post_flags
|
||||
resources :post_approvals, only: [:index]
|
||||
resources :post_disapprovals, only: [:create, :index]
|
||||
resources :post_versions, :only => [:index, :search] do
|
||||
member do
|
||||
put :undo
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
require 'test_helper'
|
||||
|
||||
module Moderator
|
||||
module Post
|
||||
class DisapprovalsControllerTest < ActionDispatch::IntegrationTest
|
||||
context "The moderator post disapprovals controller" do
|
||||
setup do
|
||||
@admin = create(:admin_user)
|
||||
as_user do
|
||||
@post = create(:post, :is_pending => true)
|
||||
end
|
||||
|
||||
CurrentUser.user = @admin
|
||||
end
|
||||
|
||||
context "create action" do
|
||||
should "render" do
|
||||
assert_difference("PostDisapproval.count", 1) do
|
||||
post_auth moderator_post_disapprovals_path, @admin, params: { post_disapproval: { post_id: @post.id, reason: "breaks_rules" }, format: "js" }
|
||||
end
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
context "for json" do
|
||||
should "render" do
|
||||
assert_difference("PostDisapproval.count", 1) do
|
||||
post_auth moderator_post_disapprovals_path, @admin, params: { post_disapproval: { post_id: @post.id, reason: "breaks_rules" }, format: "json" }
|
||||
end
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "index action" do
|
||||
should "render" do
|
||||
disapproval = FactoryBot.create(:post_disapproval, post: @post)
|
||||
get_auth moderator_post_disapprovals_path, @admin
|
||||
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
41
test/functional/post_disapprovals_controller_test.rb
Normal file
41
test/functional/post_disapprovals_controller_test.rb
Normal file
@@ -0,0 +1,41 @@
|
||||
require 'test_helper'
|
||||
|
||||
class PostDisapprovalsControllerTest < ActionDispatch::IntegrationTest
|
||||
context "The post disapprovals controller" do
|
||||
setup do
|
||||
@admin = create(:admin_user)
|
||||
as_user do
|
||||
@post = create(:post, :is_pending => true)
|
||||
end
|
||||
|
||||
CurrentUser.user = @admin
|
||||
end
|
||||
|
||||
context "create action" do
|
||||
should "render" do
|
||||
assert_difference("PostDisapproval.count", 1) do
|
||||
post_auth moderator_post_disapprovals_path, @admin, params: { post_disapproval: { post_id: @post.id, reason: "breaks_rules" }, format: "js" }
|
||||
end
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
context "for json" do
|
||||
should "render" do
|
||||
assert_difference("PostDisapproval.count", 1) do
|
||||
post_auth moderator_post_disapprovals_path, @admin, params: { post_disapproval: { post_id: @post.id, reason: "breaks_rules" }, format: "json" }
|
||||
end
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "index action" do
|
||||
should "render" do
|
||||
disapproval = FactoryBot.create(:post_disapproval, post: @post)
|
||||
get_auth moderator_post_disapprovals_path, @admin
|
||||
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user