added post#annihilate, removed stale post_moderation views

This commit is contained in:
albert
2011-10-15 23:07:50 -04:00
parent 81dc20c58f
commit 57c922ec30
18 changed files with 50 additions and 66 deletions

View File

@@ -1,6 +1,8 @@
module Moderator
module Post
class ApprovalsController < ApplicationController
before_filter :janitor_only
def create
@post = ::Post.find(params[:post_id])
@post.approve!

View File

@@ -1,14 +1,11 @@
module Moderator
module Post
class DisapprovalsController < ApplicationController
before_filter :janitor_only
def create
@post = ::Post.find(params[:post_id])
@post_disapproval = PostDisapproval.create(:post => @post, :user => CurrentUser.user)
if @post_disapproval.errors.any?
raise ::Post::DisapprovalError.new(@post_disapproval.errors.full_messages)
end
# js: redirect to dashboard
end
end
end

View File

@@ -1,6 +1,9 @@
module Moderator
module Post
class PostsController < ApplicationController
before_filter :janitor_only, :only => [:delete, :undelete]
before_filter :admin_only, :only => [:annihilate]
def delete
@post = ::Post.find(params[:id])
@post.delete!
@@ -10,6 +13,11 @@ module Moderator
@post = ::Post.find(params[:id])
@post.undelete!
end
def annihilate
@post = ::Post.find(params[:id])
@post.annihilate!
end
end
end
end

View File

@@ -893,6 +893,11 @@ class Post < ActiveRecord::Base
end
module DeletionMethods
def annihilate!
delete!
destroy
end
def delete!
Post.transaction do
give_favorites_to_parent

View File

@@ -1 +1,6 @@
$("#post-<%= @post.id %>").remove();
$("#c-posts #approve").hide();
$("#c-posts #disapprove").hide();
$("#c-posts #flag").show();
$("#c-post-moderation #post-<%= @post.id %>").hide();
Danbooru.notice("Post was approved");

View File

@@ -1 +1,13 @@
$("#post-<%= @post.id %>").remove();
<% if @post_disapproval.errors.any? %>
Danbooru.j_error("Error: " + "<%= j @post_disapproval.errors.full_messages.join("; ") %>");
<% else %>
$("#c-posts #approve").hide();
$("#c-posts #disapprove").hide();
$("#c-post-moderation #post-<%= @post.id %>").hide();
Danbooru.notice("Post was disapproved");
<% end %>

View File

@@ -0,0 +1 @@
Danbooru.notice("Post was annihilated");

View File

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

View File

@@ -0,0 +1,3 @@
$("#c-posts #delete").show();
$("#c-posts #undelete").hide();
Danbooru.notice("Post was undeleted");

View File

@@ -1 +0,0 @@
Danbooru.j_error(<%= @exception.message.to_json.html_safe %>);

View File

@@ -1,5 +0,0 @@
$("#c-posts a#approve").hide();
$("#c-posts a#disapprove").hide();
$("#c-posts a#flag").show();
$("#c-post-moderation #post-<%= @post.id %>").hide();

View File

@@ -1,2 +0,0 @@
$("a#delete").hide();
$("a#undelete").show();

View File

@@ -1 +0,0 @@
Danbooru.j_error("You have already disapproved this post");

View File

@@ -1,4 +0,0 @@
$("#c-posts a#approve").hide();
$("#c-posts a#disapprove").hide();
$("#c-post-moderation #post-<%= @post.id %>").hide();

View File

@@ -1,42 +0,0 @@
<div id="c-post-moderation">
<div id="a-moderate">
<div id="search">
<%= form_tag(post_moderation_moderate_path, :method => :get) do %>
<%= text_field_tag "query", params[:query], :size => 40 %>
<%= submit_tag "Search" %>
<% end %>
</div>
<div>
<h2>Moderation Queue</h2>
<% @posts.each do |post| %>
<article id="post-<%= post.id %>">
<aside>
<%= link_to(image_tag(post.medium_file_url), post_path(post)) %>
</aside>
<section>
<ul>
<li><%= link_to "Approve", post_moderation_approve_path(:post_id => post.id), :remote => true, :method => :put %> | <%= link_to "Disapprove", post_moderation_disapprove_path(:post_id => post.id), :remote => true, :method => :put %></li>
<li>Rating: <%= post.pretty_rating %></li>
<li>Score: <%= post.score %></li>
<li>Uploader: <%= link_to(post.uploader.name, user_path(post.uploader_id)) %> <%= time_ago_in_words(post.created_at) %> ago</li>
<% if post.is_flagged? %>
<li>Flagged: <%= post_flag_reason(post) %></li>
<% end %>
<% if (post.is_flagged? || post.is_deleted?) && post.appeals.any? %>
<li>Appeals: <%= post_appeal_reason(post) %></li>
<% end %>
<li>Disapprovals: <%= post.disapprovals.count %></li>
<li>Tags: <%= post.tag_string %></li>
</ul>
</section>
<div class="clearfix"></div>
</article>
<% end %>
</div>
</div>
</div>

View File

@@ -1,3 +0,0 @@
$("a#delete").show();
$("a#undelete").hide();
$("img#undelete-wait").hide();

View File

@@ -16,5 +16,10 @@
<li><%= link_to "Undelete", undelete_moderator_post_post_path(:post_id => post.id), :remote => true, :method => :post, :id => "undelete" %></li>
<li><%= link_to "Delete", delete_moderator_post_post_path(:post_id => post.id), :remote => true, :method => :post, :id => "delete" %></li>
<% end %>
<% if CurrentUser.is_admin? %>
<li><%= link_to "Annihilate", annihilate_moderator_post_post_path(:post_id => post.id), :remote => true, :method => :post, :id => "annihilate", :confirm => "This will permanently delete this post (meaning the file will be deleted). Are you sure you want to annihilate this post?" %></li>
<% end %>
<li><%= link_to "Pool", "#", :id => "pool" %></li>
</ul>

View File

@@ -17,6 +17,7 @@ Danbooru::Application.routes.draw do
resource :disapproval, :only => [:create]
resources :posts, :only => [:delete, :undelete] do
member do
post :annihilate
post :delete
post :undelete
end