diff --git a/app/logical/post_query_builder.rb b/app/logical/post_query_builder.rb index 1fee842e0..5627af059 100644 --- a/app/logical/post_query_builder.rb +++ b/app/logical/post_query_builder.rb @@ -139,8 +139,6 @@ class PostQueryBuilder relation = relation.where("posts.is_deleted = TRUE") elsif q[:status] == "all" || q[:status] == "any" # do nothing - else - relation = relation.where("posts.is_deleted <> TRUE") end if q[:source] diff --git a/app/models/artist.rb b/app/models/artist.rb index 36dc1f840..6d5462ed6 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -173,7 +173,7 @@ class Artist < ActiveRecord::Base rescue PostFlag::Error # swallow end - post.delete! + post.delete!(:ban => true) end rescue Post::SearchError # swallow diff --git a/app/models/post.rb b/app/models/post.rb index d7f209976..642900462 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -777,6 +777,7 @@ class Post < ActiveRecord::Base update_column(:is_deleted, true) 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 diff --git a/app/presenters/post_presenter.rb b/app/presenters/post_presenter.rb index 0a37a5c86..470e87c62 100644 --- a/app/presenters/post_presenter.rb +++ b/app/presenters/post_presenter.rb @@ -1,6 +1,10 @@ class PostPresenter < Presenter def self.preview(post, options = {}) - if post.is_deleted? && !CurrentUser.is_privileged? + if post.is_deleted? && options[:tags] !~ /status:(?:all|any|deleted)/ + return "" + end + + if post.is_banned? && !CurrentUser.is_privileged? return "" end @@ -12,6 +16,7 @@ class PostPresenter < Presenter flags << "pending" if post.is_pending? flags << "flagged" if post.is_flagged? flags << "deleted" if post.is_deleted? + flags << "banned" if post.is_banned? path = options[:path_prefix] || "/posts" @@ -63,7 +68,7 @@ class PostPresenter < Presenter end def image_html(template) - return template.content_tag("p", "This image was deleted.") if @post.is_deleted? && !CurrentUser.user.is_privileged? + return template.content_tag("p", "The artist requested removal of this image") if @post.is_banned? && !CurrentUser.user.is_privileged? return template.content_tag("p", "You need a privileged account to see this image.") if !Danbooru.config.can_user_see_post?(CurrentUser.user, @post) if @post.is_flash? diff --git a/app/views/posts/partials/show/_notices.html.erb b/app/views/posts/partials/show/_notices.html.erb index 2ba274237..800ce596f 100644 --- a/app/views/posts/partials/show/_notices.html.erb +++ b/app/views/posts/partials/show/_notices.html.erb @@ -8,7 +8,11 @@ <% if post.is_deleted? && post.flags.empty? %>
- This post was deleted + <% if post.is_banned? %> + This post was deleted because it was requested by the artist + <% else %> + This post was deleted + <% end %>
<% end %> diff --git a/db/migrate/20130321144736_remove_up_score_from_posts.rb b/db/migrate/20130321144736_remove_up_score_from_posts.rb index cdb0c3be8..849ffee90 100644 --- a/db/migrate/20130321144736_remove_up_score_from_posts.rb +++ b/db/migrate/20130321144736_remove_up_score_from_posts.rb @@ -6,5 +6,8 @@ class RemoveUpScoreFromPosts < ActiveRecord::Migration end def down + execute "set statement_timeout = 0" + add_column :posts, :up_score, :integer + add_column :posts, :up_score, :integer end end diff --git a/db/migrate/20130322162059_add_is_banned_to_posts.rb b/db/migrate/20130322162059_add_is_banned_to_posts.rb new file mode 100644 index 000000000..bd22ded7f --- /dev/null +++ b/db/migrate/20130322162059_add_is_banned_to_posts.rb @@ -0,0 +1,14 @@ +class AddIsBannedToPosts < ActiveRecord::Migration + def up + execute("set statement_timeout = 0") + add_column :posts, :is_banned, :boolean, :null => false, :default => false + Artist.banned.each do |artist| + Post.raw_tag_match(artist.name).each do |post| + post.update_column(:is_banned, true) + end + end + PostFlag.where("reason ilike '%requested%' and reason <> 'Artist requested removal'").each do |flag| + flag.post.update_column(:is_banned, true) + end + end +end diff --git a/db/structure.sql b/db/structure.sql index 9aa6e6907..4b6efdb94 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -2280,7 +2280,8 @@ CREATE TABLE posts ( image_width integer NOT NULL, image_height integer NOT NULL, parent_id integer, - has_children boolean DEFAULT false NOT NULL + has_children boolean DEFAULT false NOT NULL, + is_banned boolean DEFAULT false NOT NULL ); @@ -6263,4 +6264,6 @@ INSERT INTO schema_migrations (version) VALUES ('20130318231740'); INSERT INTO schema_migrations (version) VALUES ('20130320070700'); -INSERT INTO schema_migrations (version) VALUES ('20130321144736'); \ No newline at end of file +INSERT INTO schema_migrations (version) VALUES ('20130321144736'); + +INSERT INTO schema_migrations (version) VALUES ('20130322162059'); \ No newline at end of file diff --git a/test/unit/artist_test.rb b/test/unit/artist_test.rb index d5b8907cb..7b1db7c3a 100644 --- a/test/unit/artist_test.rb +++ b/test/unit/artist_test.rb @@ -37,6 +37,10 @@ class ArtistTest < ActiveSupport::TestCase @post.reload end + should "ban the post" do + assert(@post.is_banned?) + end + should "delete the post" do assert(@post.is_deleted?) end