diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 45a7b8dd7..6c111d3ec 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -1,5 +1,6 @@ class PostsController < ApplicationController before_filter :member_only, :except => [:show, :show_seq, :index] + before_fitler :janitor_only, :only => [:ban, :unban] after_filter :save_recent_tags, :only => [:update] respond_to :html, :xml, :json rescue_from PostSets::SearchError, :with => :rescue_exception @@ -68,6 +69,19 @@ class PostsController < ApplicationController end end + def ban + @post = Post.find(params[:id]) + @post.update_attribute(:is_banned, true) + redirect_to(post_path(@post), :notice => "Post was banned") + end + + def unban + @post = Post.find(params[:id]) + @post.update_attribute(:is_Banned, false) + redirect_to(post_path(@post), :notice => "Post was unbanned") + end + + private def tag_query params[:tags] || (params[:post] && params[:post][:tags]) diff --git a/app/views/posts/partials/show/_options.html.erb b/app/views/posts/partials/show/_options.html.erb index 5c05a866b..267a7c1c2 100644 --- a/app/views/posts/partials/show/_options.html.erb +++ b/app/views/posts/partials/show/_options.html.erb @@ -34,6 +34,12 @@
  • <%= link_to "Hide from queue", moderator_post_disapproval_path(:post_id => post.id), :remote => true, :method => :post, :id => "disapprove" %>
  • <% end %> + <% if post.is_banned? %> +
  • <%= link_to "Unban", unban_post_path(post), :method => :post %>
  • + <% else %> +
  • <%= link_to "Ban", ban_post_path(post), :method => :post %>
  • + <% end %> + <% if CurrentUser.is_admin? %>
  • <%= link_to "Expunge", expunge_moderator_post_post_path(:post_id => post.id), :remote => true, :method => :post, :id => "expunge", :confirm => "This will permanently delete this post (meaning the file will be deleted). Are you sure you want to delete this post?" %>
  • <% end %> diff --git a/config/routes.rb b/config/routes.rb index 15aacccf2..11f075bdf 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -22,6 +22,8 @@ Danbooru::Application.routes.draw do post :expunge post :delete post :undelete + post :ban + post :unban end end end