* All users can now view deleted posts.
* Posts now have an is_banned flag for artist removal requests. Basic users can not view banned posts but gold and higher can. * Banning an artist both deletes the post and bans it. * By default deleted posts are not filtered out of post searches at the sql level.
This commit is contained in:
@@ -139,8 +139,6 @@ class PostQueryBuilder
|
|||||||
relation = relation.where("posts.is_deleted = TRUE")
|
relation = relation.where("posts.is_deleted = TRUE")
|
||||||
elsif q[:status] == "all" || q[:status] == "any"
|
elsif q[:status] == "all" || q[:status] == "any"
|
||||||
# do nothing
|
# do nothing
|
||||||
else
|
|
||||||
relation = relation.where("posts.is_deleted <> TRUE")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if q[:source]
|
if q[:source]
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ class Artist < ActiveRecord::Base
|
|||||||
rescue PostFlag::Error
|
rescue PostFlag::Error
|
||||||
# swallow
|
# swallow
|
||||||
end
|
end
|
||||||
post.delete!
|
post.delete!(:ban => true)
|
||||||
end
|
end
|
||||||
rescue Post::SearchError
|
rescue Post::SearchError
|
||||||
# swallow
|
# swallow
|
||||||
|
|||||||
@@ -777,6 +777,7 @@ class Post < ActiveRecord::Base
|
|||||||
update_column(:is_deleted, true)
|
update_column(:is_deleted, true)
|
||||||
update_column(:is_pending, false)
|
update_column(:is_pending, false)
|
||||||
update_column(:is_flagged, false)
|
update_column(:is_flagged, false)
|
||||||
|
update_column(:is_banned, true) if options[:ban]
|
||||||
give_favorites_to_parent
|
give_favorites_to_parent
|
||||||
update_children_on_destroy
|
update_children_on_destroy
|
||||||
update_parent_on_destroy
|
update_parent_on_destroy
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
class PostPresenter < Presenter
|
class PostPresenter < Presenter
|
||||||
def self.preview(post, options = {})
|
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 ""
|
return ""
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -12,6 +16,7 @@ class PostPresenter < Presenter
|
|||||||
flags << "pending" if post.is_pending?
|
flags << "pending" if post.is_pending?
|
||||||
flags << "flagged" if post.is_flagged?
|
flags << "flagged" if post.is_flagged?
|
||||||
flags << "deleted" if post.is_deleted?
|
flags << "deleted" if post.is_deleted?
|
||||||
|
flags << "banned" if post.is_banned?
|
||||||
|
|
||||||
path = options[:path_prefix] || "/posts"
|
path = options[:path_prefix] || "/posts"
|
||||||
|
|
||||||
@@ -63,7 +68,7 @@ class PostPresenter < Presenter
|
|||||||
end
|
end
|
||||||
|
|
||||||
def image_html(template)
|
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)
|
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?
|
if @post.is_flash?
|
||||||
|
|||||||
@@ -8,7 +8,11 @@
|
|||||||
|
|
||||||
<% if post.is_deleted? && post.flags.empty? %>
|
<% if post.is_deleted? && post.flags.empty? %>
|
||||||
<div class="ui-corner-all ui-state-highlight notice">
|
<div class="ui-corner-all ui-state-highlight notice">
|
||||||
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 %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|||||||
@@ -6,5 +6,8 @@ class RemoveUpScoreFromPosts < ActiveRecord::Migration
|
|||||||
end
|
end
|
||||||
|
|
||||||
def down
|
def down
|
||||||
|
execute "set statement_timeout = 0"
|
||||||
|
add_column :posts, :up_score, :integer
|
||||||
|
add_column :posts, :up_score, :integer
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
14
db/migrate/20130322162059_add_is_banned_to_posts.rb
Normal file
14
db/migrate/20130322162059_add_is_banned_to_posts.rb
Normal file
@@ -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
|
||||||
@@ -2280,7 +2280,8 @@ CREATE TABLE posts (
|
|||||||
image_width integer NOT NULL,
|
image_width integer NOT NULL,
|
||||||
image_height integer NOT NULL,
|
image_height integer NOT NULL,
|
||||||
parent_id integer,
|
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 ('20130320070700');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20130321144736');
|
INSERT INTO schema_migrations (version) VALUES ('20130321144736');
|
||||||
|
|
||||||
|
INSERT INTO schema_migrations (version) VALUES ('20130322162059');
|
||||||
@@ -37,6 +37,10 @@ class ArtistTest < ActiveSupport::TestCase
|
|||||||
@post.reload
|
@post.reload
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "ban the post" do
|
||||||
|
assert(@post.is_banned?)
|
||||||
|
end
|
||||||
|
|
||||||
should "delete the post" do
|
should "delete the post" do
|
||||||
assert(@post.is_deleted?)
|
assert(@post.is_deleted?)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user