* 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:
albert
2013-03-22 09:38:53 -07:00
parent 733fa2dd7b
commit 6c54d89a36
9 changed files with 40 additions and 8 deletions

View File

@@ -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]

View File

@@ -173,7 +173,7 @@ class Artist < ActiveRecord::Base
rescue PostFlag::Error
# swallow
end
post.delete!
post.delete!(:ban => true)
end
rescue Post::SearchError
# swallow

View File

@@ -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

View File

@@ -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?

View File

@@ -8,7 +8,11 @@
<% if post.is_deleted? && post.flags.empty? %>
<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>
<% end %>