diff --git a/app/logical/anonymous_user.rb b/app/logical/anonymous_user.rb index 9215ace0c..eafd3f2fe 100644 --- a/app/logical/anonymous_user.rb +++ b/app/logical/anonymous_user.rb @@ -176,6 +176,10 @@ class AnonymousUser def per_page Danbooru.config.posts_per_page end + + def hide_deleted_posts? + false + end %w(member banned privileged builder platinum contributor janitor moderator admin).each do |name| define_method("is_#{name}?") do diff --git a/app/logical/post_query_builder.rb b/app/logical/post_query_builder.rb index 739748356..ac2971ccc 100644 --- a/app/logical/post_query_builder.rb +++ b/app/logical/post_query_builder.rb @@ -147,6 +147,8 @@ class PostQueryBuilder relation = relation.where("posts.is_flagged = FALSE") elsif q[:status_neg] == "deleted" relation = relation.where("posts.is_deleted = FALSE") + elsif CurrentUser.user.hide_deleted_posts? + relation = relation.where("posts.is_deleted = FALSE") end if q[:source] diff --git a/app/models/user.rb b/app/models/user.rb index 8547ae4af..adce5c8c9 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -17,7 +17,7 @@ class User < ActiveRecord::Base end attr_accessor :password, :old_password - attr_accessible :enable_privacy_mode, :enable_post_navigation, :new_post_navigation_layout, :password, :old_password, :password_confirmation, :password_hash, :email, :last_logged_in_at, :last_forum_read_at, :has_mail, :receive_email_notifications, :comment_threshold, :always_resize_images, :favorite_tags, :blacklisted_tags, :name, :ip_addr, :time_zone, :default_image_size, :enable_sequential_post_navigation, :per_page, :as => [:moderator, :janitor, :contributor, :privileged, :member, :anonymous, :default, :builder, :admin] + attr_accessible :enable_privacy_mode, :enable_post_navigation, :new_post_navigation_layout, :password, :old_password, :password_confirmation, :password_hash, :email, :last_logged_in_at, :last_forum_read_at, :has_mail, :receive_email_notifications, :comment_threshold, :always_resize_images, :favorite_tags, :blacklisted_tags, :name, :ip_addr, :time_zone, :default_image_size, :enable_sequential_post_navigation, :per_page, :hide_deleted_posts, :as => [:moderator, :janitor, :contributor, :privileged, :member, :anonymous, :default, :builder, :admin] attr_accessible :level, :as => :admin validates_length_of :name, :within => 2..100, :on => :create validates_format_of :name, :with => /\A[^\s:]+\Z/, :on => :create, :message => "cannot have whitespace or colons" diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index 4f605f7fd..0a9456c6d 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -4,6 +4,7 @@ <%= simple_form_for @user do |f| %>
+ Basic Settings

Name changes are not supported. <%= link_to "Read why", name_change_path %>.

@@ -12,16 +13,22 @@ <%= f.input :time_zone, :include_blank => false %> <%= f.input :receive_email_notifications, :as => :select, :include_blank => false %> <%= f.input :comment_threshold, :hint => "Comments below this score will be hidden by default" %> - <%= f.input :always_resize_images, :as => :select, :include_blank => false, :label => "Fit images to window", :hint => "Use JavaScript to resize images to fit window" %> <%= f.input :default_image_size, :hint => "Show original image or show resampled #{Danbooru.config.large_image_width} pixel version", :label => "Image size", :collection => %w(large original), :include_blank => false %> - <%= f.input :enable_post_navigation, :as => :select, :include_blank => false, :label => "Enable keyboard shortcuts" %> - <%= f.input :new_post_navigation_layout, :as => :select, :label => "Pool links", :include_blank => false, :collection => [["Bottom", "true"], ["Top", "false"]], :hint => "When browsing pools, where do you want the navigation links to be placed?" %> - <%= f.input :enable_sequential_post_navigation, :as => :select, :label => "Enable slideshow mode", :hint => "Show prev/next links when viewing a post", :include_blank => false %> <%= f.input :per_page, :label => "Posts per page", :as => :select, :collection => (1..100), :include_blank => false %> <%= f.input :blacklisted_tags, :hint => "Put any tag combinations you never want to see here. Each combination should go on a separate line.", :input_html => {:size => "40x5"} %>
+ +
+ Advanced Settings + <%= f.input :always_resize_images, :as => :select, :include_blank => false, :label => "Fit images to window", :hint => "Use JavaScript to resize images to fit window" %> + <%= f.input :enable_post_navigation, :as => :select, :include_blank => false, :label => "Enable keyboard shortcuts" %> + <%= f.input :new_post_navigation_layout, :as => :select, :label => "Pool links", :include_blank => false, :collection => [["Bottom", "true"], ["Top", "false"]], :hint => "When browsing pools, where do you want the navigation links to be placed?" %> + <%= f.input :enable_sequential_post_navigation, :as => :select, :label => "Enable slideshow mode", :hint => "Show prev/next links when viewing a post", :include_blank => false %> + <%= f.input :hide_deleted_posts, :as => :select, :label => "Deleted post filter", :hint => "Hide deleted posts at the database level", :include_blank => false, :collection => [["Yes", "true"], ["No", "false"]] %> +
+ Change Password <%= f.input :password, :hint => "Leave blank if you don't want to change your password", :label => "New password", :input_html => {:autocomplete => "off"} %> <%= f.input :old_password, :as => :password, :input_html => {:autocomplete => "off"} %>
diff --git a/db/migrate/20130323160259_add_hide_deleted_posts_to_users.rb b/db/migrate/20130323160259_add_hide_deleted_posts_to_users.rb new file mode 100644 index 000000000..5f321e0ef --- /dev/null +++ b/db/migrate/20130323160259_add_hide_deleted_posts_to_users.rb @@ -0,0 +1,5 @@ +class AddHideDeletedPostsToUsers < ActiveRecord::Migration + def change + add_column :users, :hide_deleted_posts, :boolean, :null => false, :default => false + end +end diff --git a/db/structure.sql b/db/structure.sql index 1d2d346b5..9102bb82d 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -2607,7 +2607,8 @@ CREATE TABLE users ( new_post_navigation_layout boolean DEFAULT true NOT NULL, enable_privacy_mode boolean DEFAULT false NOT NULL, enable_sequential_post_navigation boolean DEFAULT true NOT NULL, - per_page integer DEFAULT 20 NOT NULL + per_page integer DEFAULT 20 NOT NULL, + hide_deleted_posts boolean DEFAULT false NOT NULL ); @@ -6275,4 +6276,6 @@ INSERT INTO schema_migrations (version) VALUES ('20130322162059'); INSERT INTO schema_migrations (version) VALUES ('20130322173202'); -INSERT INTO schema_migrations (version) VALUES ('20130322173859'); \ No newline at end of file +INSERT INTO schema_migrations (version) VALUES ('20130322173859'); + +INSERT INTO schema_migrations (version) VALUES ('20130323160259'); \ No newline at end of file