pundit: convert moderator/post/posts to pundit.

This commit is contained in:
evazion
2020-03-20 02:28:16 -05:00
parent 1344d4c161
commit d51b0dfe17
4 changed files with 34 additions and 24 deletions

View File

@@ -1,10 +1,7 @@
module Moderator
module Post
class PostsController < ApplicationController
before_action :approver_only, :only => [:delete, :move_favorites, :ban, :unban, :confirm_delete, :confirm_move_favorites]
before_action :admin_only, :only => [:expunge]
skip_before_action :api_check
respond_to :html, :json, :xml, :js
def confirm_delete
@@ -12,7 +9,7 @@ module Moderator
end
def delete
@post = ::Post.find(params[:id])
@post = authorize ::Post.find(params[:id])
if params[:commit] == "Delete"
@post.delete!(params[:reason], :move_favorites => params[:move_favorites].present?)
end
@@ -24,7 +21,7 @@ module Moderator
end
def move_favorites
@post = ::Post.find(params[:id])
@post = authorize ::Post.find(params[:id])
if params[:commit] == "Submit"
@post.give_favorites_to_parent
end
@@ -32,12 +29,12 @@ module Moderator
end
def expunge
@post = ::Post.find(params[:id])
@post = authorize ::Post.find(params[:id])
@post.expunge!
end
def ban
@post = ::Post.find(params[:id])
@post = authorize ::Post.find(params[:id])
@post.ban!
flash[:notice] = "Post was banned"
@@ -45,7 +42,7 @@ module Moderator
end
def unban
@post = ::Post.find(params[:id])
@post = authorize ::Post.find(params[:id])
@post.unban!
flash[:notice] = "Post was banned"