Remove `POST /moderator/post/undelete` endpoint. Replace it with `POST /post_approvals` instead. Fixes it so that undeleting a post has the same behavior as approving a post. Namely, it reloads the page instead of just flashing a "Post was undeleted" message.
66 lines
1.6 KiB
Ruby
66 lines
1.6 KiB
Ruby
module Moderator
|
|
module Post
|
|
class PostsController < ApplicationController
|
|
before_action :approver_only, :only => [:delete, :move_favorites, :ban, :unban, :confirm_delete, :confirm_move_favorites, :confirm_ban]
|
|
before_action :admin_only, :only => [:expunge]
|
|
skip_before_action :api_check
|
|
|
|
respond_to :html, :json, :xml
|
|
|
|
def confirm_delete
|
|
@post = ::Post.find(params[:id])
|
|
end
|
|
|
|
def delete
|
|
@post = ::Post.find(params[:id])
|
|
if params[:commit] == "Delete"
|
|
@post.delete!(params[:reason], :move_favorites => params[:move_favorites].present?)
|
|
end
|
|
redirect_to(post_path(@post))
|
|
end
|
|
|
|
def confirm_move_favorites
|
|
@post = ::Post.find(params[:id])
|
|
end
|
|
|
|
def move_favorites
|
|
@post = ::Post.find(params[:id])
|
|
if params[:commit] == "Submit"
|
|
@post.give_favorites_to_parent
|
|
end
|
|
redirect_to(post_path(@post))
|
|
end
|
|
|
|
def expunge
|
|
@post = ::Post.find(params[:id])
|
|
@post.expunge!
|
|
end
|
|
|
|
def confirm_ban
|
|
@post = ::Post.find(params[:id])
|
|
end
|
|
|
|
def ban
|
|
@post = ::Post.find(params[:id])
|
|
if params[:commit] == "Ban"
|
|
@post.ban!
|
|
end
|
|
|
|
respond_to do |fmt|
|
|
fmt.html do
|
|
redirect_to(post_path(@post), :notice => "Post was banned")
|
|
end
|
|
|
|
fmt.js
|
|
end
|
|
end
|
|
|
|
def unban
|
|
@post = ::Post.find(params[:id])
|
|
@post.unban!
|
|
redirect_to(post_path(@post), :notice => "Post was unbanned")
|
|
end
|
|
end
|
|
end
|
|
end
|