Merge branch 'master' of github.com:r888888888/danbooru

This commit is contained in:
r888888888
2013-05-06 10:20:33 -07:00
30 changed files with 219 additions and 115 deletions

View File

@@ -1,6 +1,6 @@
class NewsUpdate < ActiveRecord::Base
belongs_to :creator, :class_name => "User"
belongs_to :udpater, :class_name => "User"
belongs_to :updater, :class_name => "User"
scope :recent, order("created_at desc").limit(5)
before_validation :initialize_creator, :on => :create
before_validation :initialize_updater

View File

@@ -68,9 +68,6 @@ class PostFlag < ActiveRecord::Base
if post.is_deleted?
errors[:post] << "is deleted"
false
elsif post.is_pending?
errors[:post] << "is pending"
false
else
true
end

View File

@@ -6,7 +6,7 @@ class TagSubscription < ActiveRecord::Base
before_save :limit_tag_count
attr_accessible :name, :tag_query, :post_ids, :is_public, :is_visible_on_profile
validates_presence_of :name, :tag_query, :creator_id
validates_format_of :tag_query, :with => /^(?:\S+\s*){1,20}$/m, :message => "can have up to 20 tags"
validates_format_of :tag_query, :with => /\A(?:\S*\s*){1,20}\Z/, :message => "can have up to 20 tags"
validate :creator_can_create_subscriptions, :on => :create
def normalize_name

View File

@@ -510,13 +510,15 @@ class User < ActiveRecord::Base
module ApiMethods
def hidden_attributes
super + [:password_hash, :bcrypt_password_hash, :email, :email_verification_key, :time_zone, :created_at, :updated_at, :receive_email_notifications, :last_logged_in_at, :last_forum_read_at, :has_mail, :default_image_size, :comment_threshold, :always_resize_images, :favorite_tags, :blacklisted_tags, :base_upload_limit, :recent_tags, :enable_privacy_mode, :enable_post_navigation, :new_post_navigation_layout, :enable_sequential_post_navigation, :hide_deleted_posts, :per_page, :style_usernames]
super + [:password_hash, :bcrypt_password_hash, :email, :email_verification_key, :time_zone, :updated_at, :receive_email_notifications, :last_logged_in_at, :last_forum_read_at, :has_mail, :default_image_size, :comment_threshold, :always_resize_images, :favorite_tags, :blacklisted_tags, :recent_tags, :enable_privacy_mode, :enable_post_navigation, :new_post_navigation_layout, :enable_sequential_post_navigation, :hide_deleted_posts, :per_page, :style_usernames]
end
def serializable_hash(options = {})
options ||= {}
options[:except] ||= []
options[:except] += hidden_attributes
options[:methods] ||= []
options[:methods] += [:wiki_page_version_count, :artist_version_count, :pool_version_count, :forum_post_count, :comment_count]
super(options)
end
@@ -525,6 +527,8 @@ class User < ActiveRecord::Base
options ||= {}
options[:except] ||= []
options[:except] += hidden_attributes
options[:methods] ||= []
options[:methods] += [:wiki_page_version_count, :artist_version_count, :pool_version_count, :forum_post_count, :comment_count]
super(options, &block)
end
@@ -538,6 +542,28 @@ class User < ActiveRecord::Base
end
end
module CountMethods
def wiki_page_version_count
WikiPageVersion.for_user(id).count
end
def artist_version_count
ArtistVersion.for_user(id).count
end
def pool_version_count
PoolVersion.for_user(id).count
end
def forum_post_count
ForumPost.for_user(id).count
end
def comment_count
Comment.for_creator(id).count
end
end
module SearchMethods
def named(name)
where("lower(name) = ?", name)
@@ -628,6 +654,7 @@ class User < ActiveRecord::Base
include LimitMethods
include InvitationMethods
include ApiMethods
include CountMethods
extend SearchMethods
def initialize_default_image_size