fixes #959
This commit is contained in:
@@ -172,6 +172,10 @@ class AnonymousUser
|
|||||||
def statement_timeout
|
def statement_timeout
|
||||||
3_000
|
3_000
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def per_page
|
||||||
|
Danbooru.config.posts_per_page
|
||||||
|
end
|
||||||
|
|
||||||
%w(member banned privileged builder platinum contributor janitor moderator admin).each do |name|
|
%w(member banned privileged builder platinum contributor janitor moderator admin).each do |name|
|
||||||
define_method("is_#{name}?") do
|
define_method("is_#{name}?") do
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ module PostSets
|
|||||||
def initialize(tags, page = 1, per_page = nil)
|
def initialize(tags, page = 1, per_page = nil)
|
||||||
@tag_array = Tag.scan_query(tags)
|
@tag_array = Tag.scan_query(tags)
|
||||||
@page = page
|
@page = page
|
||||||
@per_page = (per_page || Danbooru.config.posts_per_page).to_i
|
@per_page = (per_page || CurrentUser.per_page).to_i
|
||||||
@per_page = 200 if @per_page > 200
|
@per_page = 200 if @per_page > 200
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class User < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
attr_accessor :password, :old_password
|
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, :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, :as => [:moderator, :janitor, :contributor, :privileged, :member, :anonymous, :default, :builder, :admin]
|
||||||
attr_accessible :level, :as => :admin
|
attr_accessible :level, :as => :admin
|
||||||
validates_length_of :name, :within => 2..100, :on => :create
|
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"
|
validates_format_of :name, :with => /\A[^\s:]+\Z/, :on => :create, :message => "cannot have whitespace or colons"
|
||||||
@@ -25,11 +25,13 @@ class User < ActiveRecord::Base
|
|||||||
validates_uniqueness_of :email, :case_sensitive => false, :if => lambda {|rec| rec.email.present?}
|
validates_uniqueness_of :email, :case_sensitive => false, :if => lambda {|rec| rec.email.present?}
|
||||||
validates_length_of :password, :minimum => 5, :if => lambda {|rec| rec.new_record? || rec.password.present?}
|
validates_length_of :password, :minimum => 5, :if => lambda {|rec| rec.new_record? || rec.password.present?}
|
||||||
validates_inclusion_of :default_image_size, :in => %w(large original)
|
validates_inclusion_of :default_image_size, :in => %w(large original)
|
||||||
|
validates_inclusion_of :per_page, :in => [20, 50, 100]
|
||||||
validates_confirmation_of :password
|
validates_confirmation_of :password
|
||||||
validates_presence_of :email, :if => lambda {|rec| rec.new_record? && Danbooru.config.enable_email_verification?}
|
validates_presence_of :email, :if => lambda {|rec| rec.new_record? && Danbooru.config.enable_email_verification?}
|
||||||
validates_presence_of :comment_threshold
|
validates_presence_of :comment_threshold
|
||||||
validate :validate_ip_addr_is_not_banned, :on => :create
|
validate :validate_ip_addr_is_not_banned, :on => :create
|
||||||
before_validation :normalize_blacklisted_tags
|
before_validation :normalize_blacklisted_tags
|
||||||
|
before_validation :set_per_page
|
||||||
before_create :encrypt_password_on_create
|
before_create :encrypt_password_on_create
|
||||||
before_update :encrypt_password_on_update
|
before_update :encrypt_password_on_update
|
||||||
after_save :update_cache
|
after_save :update_cache
|
||||||
@@ -345,6 +347,10 @@ class User < ActiveRecord::Base
|
|||||||
ModAction.create(:description => "#{name} level changed #{level_string(level_was)} -> #{level_string} by #{CurrentUser.name}")
|
ModAction.create(:description => "#{name} level changed #{level_string(level_was)} -> #{level_string} by #{CurrentUser.name}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_per_page
|
||||||
|
self.per_page = Danbooru.config.posts_per_page unless is_privileged?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
module EmailMethods
|
module EmailMethods
|
||||||
|
|||||||
@@ -17,6 +17,10 @@
|
|||||||
<%= f.input :enable_post_navigation, :as => :select, :include_blank => false, :label => "Enable keyboard shortcuts" %>
|
<%= 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 :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 :enable_sequential_post_navigation, :as => :select, :label => "Enable slideshow mode", :hint => "Show prev/next links when viewing a post", :include_blank => false %>
|
||||||
|
|
||||||
|
<% if CurrentUser.is_privileged? %>
|
||||||
|
<%= f.input :per_page, :as => :select, :label => "Posts per page", :collection => [20, 50, 100], :include_blank => false %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<div class="input text optional field_with_hint">
|
<div class="input text optional field_with_hint">
|
||||||
<label class="text optional" for="user_favorite_tags">Favorite tags</label>
|
<label class="text optional" for="user_favorite_tags">Favorite tags</label>
|
||||||
|
|||||||
@@ -79,6 +79,12 @@
|
|||||||
<td>6 sec</td>
|
<td>6 sec</td>
|
||||||
<td>9 sec</td>
|
<td>9 sec</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>50 or 100 Posts Per Page</td>
|
||||||
|
<td>No</td>
|
||||||
|
<td>Yes</td>
|
||||||
|
<td>Yes</td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
6
db/migrate/20130322173202_add_per_page_to_users.rb
Normal file
6
db/migrate/20130322173202_add_per_page_to_users.rb
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
class AddPerPageToUsers < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
execute("set statement_timeout = 0")
|
||||||
|
add_column :users, :per_page, :integer, :null => false, :default => 20
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -2602,7 +2602,8 @@ CREATE TABLE users (
|
|||||||
enable_post_navigation boolean DEFAULT true NOT NULL,
|
enable_post_navigation boolean DEFAULT true NOT NULL,
|
||||||
new_post_navigation_layout boolean DEFAULT true NOT NULL,
|
new_post_navigation_layout boolean DEFAULT true NOT NULL,
|
||||||
enable_privacy_mode boolean DEFAULT false NOT NULL,
|
enable_privacy_mode boolean DEFAULT false NOT NULL,
|
||||||
enable_sequential_post_navigation boolean DEFAULT true NOT NULL
|
enable_sequential_post_navigation boolean DEFAULT true NOT NULL,
|
||||||
|
per_page integer DEFAULT 20 NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -6266,4 +6267,6 @@ 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');
|
INSERT INTO schema_migrations (version) VALUES ('20130322162059');
|
||||||
|
|
||||||
|
INSERT INTO schema_migrations (version) VALUES ('20130322173202');
|
||||||
@@ -81,7 +81,7 @@ module Danbooru
|
|||||||
def option_for(key)
|
def option_for(key)
|
||||||
case key
|
case key
|
||||||
when :limit
|
when :limit
|
||||||
limit = @paginator_options.try(:[], :limit) || Danbooru.config.posts_per_page
|
limit = @paginator_options.try(:[], :limit) || CurrentUser.user.per_page
|
||||||
if limit.to_i > 1_000
|
if limit.to_i > 1_000
|
||||||
limit = 1_000
|
limit = 1_000
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user