more work

This commit is contained in:
albert
2010-10-19 19:34:31 -04:00
parent cb3d7e9e9b
commit acdce69f20
48 changed files with 2494 additions and 1585 deletions

View File

@@ -8,7 +8,7 @@ class Post < ActiveRecord::Base
before_save :create_tags
before_save :update_tag_post_counts
before_save :set_tag_counts
before_validation_on_create :initialize_uploader
before_validation :initialize_uploader, :on => :create
belongs_to :updater, :class_name => "User"
belongs_to :approver, :class_name => "User"
belongs_to :parent, :class_name => "Post"
@@ -25,6 +25,7 @@ class Post < ActiveRecord::Base
validate :validate_parent_does_not_have_a_parent
attr_accessible :source, :rating, :tag_string, :old_tag_string, :last_noted_at
scope :visible, lambda {|user| Danbooru.config.can_user_see_post_conditions(user)}
scope :commented_before, lambda {|date| where("last_commented_at < ?", date).order("last_commented_at DESC")}
module FileMethods
def delete_files

View File

@@ -312,9 +312,8 @@ class Tag < ActiveRecord::Base
module RelationMethods
def update_related
calculator = RelatedTagCalculator.new
counts = calculator.calculate_from_sample(Danbooru.config.post_sample_size, name)
self.related_tags = calculator.convert_hash_to_string(counts)
counts = RelatedTagCalculator.calculate_from_sample(Danbooru.config.post_sample_size, name)
self.related_tags = RelatedTagCalculator.convert_hash_to_string(counts)
end
def update_related_if_outdated

View File

@@ -7,8 +7,8 @@ class Upload < ActiveRecord::Base
attr_accessor :file, :image_width, :image_height, :file_ext, :md5, :file_size
belongs_to :uploader, :class_name => "User"
belongs_to :post
before_validation_on_create :initialize_uploader
before_validation_on_create :initialize_status
before_validation :initialize_uploader, :on => :create
before_validation :initialize_status, :on => :create
before_create :convert_cgi_file
validate :uploader_is_not_limited