added post#annihilate, removed stale post_moderation views
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
module Moderator
|
module Moderator
|
||||||
module Post
|
module Post
|
||||||
class ApprovalsController < ApplicationController
|
class ApprovalsController < ApplicationController
|
||||||
|
before_filter :janitor_only
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@post = ::Post.find(params[:post_id])
|
@post = ::Post.find(params[:post_id])
|
||||||
@post.approve!
|
@post.approve!
|
||||||
|
|||||||
@@ -1,14 +1,11 @@
|
|||||||
module Moderator
|
module Moderator
|
||||||
module Post
|
module Post
|
||||||
class DisapprovalsController < ApplicationController
|
class DisapprovalsController < ApplicationController
|
||||||
|
before_filter :janitor_only
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@post = ::Post.find(params[:post_id])
|
@post = ::Post.find(params[:post_id])
|
||||||
@post_disapproval = PostDisapproval.create(:post => @post, :user => CurrentUser.user)
|
@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
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
module Moderator
|
module Moderator
|
||||||
module Post
|
module Post
|
||||||
class PostsController < ApplicationController
|
class PostsController < ApplicationController
|
||||||
|
before_filter :janitor_only, :only => [:delete, :undelete]
|
||||||
|
before_filter :admin_only, :only => [:annihilate]
|
||||||
|
|
||||||
def delete
|
def delete
|
||||||
@post = ::Post.find(params[:id])
|
@post = ::Post.find(params[:id])
|
||||||
@post.delete!
|
@post.delete!
|
||||||
@@ -10,6 +13,11 @@ module Moderator
|
|||||||
@post = ::Post.find(params[:id])
|
@post = ::Post.find(params[:id])
|
||||||
@post.undelete!
|
@post.undelete!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def annihilate
|
||||||
|
@post = ::Post.find(params[:id])
|
||||||
|
@post.annihilate!
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -893,6 +893,11 @@ class Post < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
module DeletionMethods
|
module DeletionMethods
|
||||||
|
def annihilate!
|
||||||
|
delete!
|
||||||
|
destroy
|
||||||
|
end
|
||||||
|
|
||||||
def delete!
|
def delete!
|
||||||
Post.transaction do
|
Post.transaction do
|
||||||
give_favorites_to_parent
|
give_favorites_to_parent
|
||||||
|
|||||||
@@ -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");
|
||||||
@@ -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 %>
|
||||||
1
app/views/moderator/post/posts/annihilate.js.erb
Normal file
1
app/views/moderator/post/posts/annihilate.js.erb
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Danbooru.notice("Post was annihilated");
|
||||||
@@ -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");
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
$("#c-posts #delete").show();
|
||||||
|
$("#c-posts #undelete").hide();
|
||||||
|
Danbooru.notice("Post was undeleted");
|
||||||
@@ -1 +0,0 @@
|
|||||||
Danbooru.j_error(<%= @exception.message.to_json.html_safe %>);
|
|
||||||
@@ -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();
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
$("a#delete").hide();
|
|
||||||
$("a#undelete").show();
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
Danbooru.j_error("You have already disapproved this post");
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
$("#c-posts a#approve").hide();
|
|
||||||
$("#c-posts a#disapprove").hide();
|
|
||||||
|
|
||||||
$("#c-post-moderation #post-<%= @post.id %>").hide();
|
|
||||||
@@ -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>
|
|
||||||
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
$("a#delete").show();
|
|
||||||
$("a#undelete").hide();
|
|
||||||
$("img#undelete-wait").hide();
|
|
||||||
@@ -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 "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>
|
<li><%= link_to "Delete", delete_moderator_post_post_path(:post_id => post.id), :remote => true, :method => :post, :id => "delete" %></li>
|
||||||
<% end %>
|
<% 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>
|
<li><%= link_to "Pool", "#", :id => "pool" %></li>
|
||||||
</ul>
|
</ul>
|
||||||
@@ -17,6 +17,7 @@ Danbooru::Application.routes.draw do
|
|||||||
resource :disapproval, :only => [:create]
|
resource :disapproval, :only => [:create]
|
||||||
resources :posts, :only => [:delete, :undelete] do
|
resources :posts, :only => [:delete, :undelete] do
|
||||||
member do
|
member do
|
||||||
|
post :annihilate
|
||||||
post :delete
|
post :delete
|
||||||
post :undelete
|
post :undelete
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user