delete action from post/show requires confirmation+flag reason now

This commit is contained in:
albert
2013-02-23 16:53:03 -05:00
parent 138f3eb3db
commit 4a61498f0e
5 changed files with 27 additions and 7 deletions

View File

@@ -3,10 +3,18 @@ module Moderator
class PostsController < ApplicationController
before_filter :janitor_only, :only => [:delete, :undelete]
before_filter :admin_only, :only => [:annihilate]
def confirm_delete
@post = ::Post.find(params[:id])
end
def delete
@post = ::Post.find(params[:id])
@post.delete!
if params[:commit] == "Delete"
@post.flag!(params[:reason])
@post.delete!
end
redirect_to(post_path(@post))
end
def undelete

View File

@@ -0,0 +1,15 @@
<h1>Delete Post</h1>
<div>
<%= PostPresenter.preview(@post) %>
</div>
<%= form_tag(delete_moderator_post_post_path, :style => "clear: both;", :class => "simple_form") do %>
<div class="input">
<label for="reason">Reason</label>
<%= text_area_tag "reason" %>
</div>
<%= submit_tag "Delete" %>
<%= submit_tag "Cancel" %>
<% end %>

View File

@@ -1,4 +0,0 @@
$("#c-posts #delete").hide();
$("#c-posts #undelete").show();
$("#c-post-moderation #post-<%= @post.id %>").remove();
Danbooru.notice("Post was deleted");

View File

@@ -25,7 +25,7 @@
<% if post.is_deleted? %>
<li><%= link_to "Undelete", undelete_moderator_post_post_path(:post_id => post.id), :remote => true, :method => :post, :id => "undelete" %></li>
<% else %>
<li><%= link_to "Delete", delete_moderator_post_post_path(:post_id => post.id), :remote => true, :method => :post, :id => "delete" %></li>
<li><%= link_to "Delete", confirm_delete_moderator_post_post_path(:post_id => post.id) %></li>
<% end %>
<% end %>
<% end %>

View File

@@ -16,8 +16,9 @@ Danbooru::Application.routes.draw do
resource :queue, :only => [:show]
resource :approval, :only => [:create]
resource :disapproval, :only => [:create]
resources :posts, :only => [:delete, :undelete] do
resources :posts, :only => [:delete, :undelete, :annihilate, :confirm_delete] do
member do
get :confirm_delete
post :annihilate
post :delete
post :undelete