Fixes #1121, rename Post#annihilate to Post#expunge

This commit is contained in:
albert
2013-04-08 13:44:43 -04:00
parent 9a337346df
commit c540c4f891
10 changed files with 98 additions and 52 deletions

View File

@@ -2,7 +2,7 @@ module Moderator
module Post
class PostsController < ApplicationController
before_filter :janitor_only, :only => [:delete, :undelete]
before_filter :admin_only, :only => [:annihilate]
before_filter :admin_only, :only => [:expunge]
rescue_from ::PostFlag::Error, :with => :rescue_exception
def confirm_delete
@@ -23,9 +23,9 @@ module Moderator
@post.undelete!
end
def annihilate
def expunge
@post = ::Post.find(params[:id])
@post.annihilate!
@post.expunge!
end
end
end

View File

@@ -31,7 +31,6 @@ class Post < ActiveRecord::Base
has_many :disapprovals, :class_name => "PostDisapproval"
validates_uniqueness_of :md5
validates_presence_of :parent, :if => lambda {|rec| !rec.parent_id.nil?}
# validate :validate_parent_does_not_have_a_parent
attr_accessible :source, :rating, :tag_string, :old_tag_string, :last_noted_at, :parent_id, :as => [:member, :builder, :privileged, :platinum, :contributor, :janitor, :moderator, :admin, :default]
attr_accessible :is_rating_locked, :is_note_locked, :as => [:builder, :contributor, :janitor, :moderator, :admin]
attr_accessible :is_status_locked, :as => [:admin]
@@ -251,7 +250,6 @@ class Post < ActiveRecord::Base
self.is_deleted = false
self.approver_id = CurrentUser.id
save!
# ModAction.create(:description => "approved post ##{id}")
end
def disapproved_by?(user)
@@ -678,13 +676,13 @@ class Post < ActiveRecord::Base
# A parent has many children. A child belongs to a parent.
# A parent cannot have a parent.
#
# After deleting a child:
# After expunging a child:
# - Move favorites to parent.
# - Does the parent have any active children?
# - Yes: Done.
# - No: Update parent's has_children flag to false.
#
# After deleting a parent:
# After expunging a parent:
# - Move favorites to the first child.
# - Reparent all active children to the first active child.
@@ -756,15 +754,18 @@ class Post < ActiveRecord::Base
end
module DeletionMethods
def annihilate!
def expunge!
if is_status_locked?
self.errors.add(:is_status_locked, "; cannot delete post")
return false
end
ModAction.create(:description => "permanently deleted post ##{id}")
decrement_tag_post_counts
delete!(:without_mod_action => true)
give_favorites_to_parent
update_children_on_destroy
update_parent_on_destroy
decrement_tag_post_counts
destroy
end
@@ -779,11 +780,6 @@ class Post < ActiveRecord::Base
update_column(:is_pending, false)
update_column(:is_flagged, false)
update_column(:is_banned, true) if options[:ban]
give_favorites_to_parent
update_children_on_destroy
update_parent_on_destroy
# decrement_tag_post_counts
update_column(:parent_id, nil)
unless options[:without_mod_action]
ModAction.create(:description => "deleted post ##{id}")
@@ -801,7 +797,6 @@ class Post < ActiveRecord::Base
self.approver_id = CurrentUser.id
save
Post.expire_cache_for_all(tag_array)
update_parent_on_save
ModAction.create(:description => "undeleted post ##{id}")
end
end

View File

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

View File

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

View File

@@ -35,6 +35,6 @@
<% end %>
<% if CurrentUser.is_admin? %>
<li><%= link_to "Expunge", 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 delete this post?" %></li>
<li><%= 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?" %></li>
<% end %>
</ul>