diff --git a/app/models/photo.rb b/app/models/photo.rb index 441545d..652fb6d 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -9,12 +9,11 @@ class Photo < ActiveRecord::Base validates :title, :presence => true - before_validation :set_title, :set_path + before_validation :set_title before_create :exif_read #before_update :exif_write attr_accessor :tag_list - #attr_protected :path scope :untouched, :conditions => "photos.description IS NULL AND photos.id NOT IN ( SELECT photo_id FROM photo_tags)", :include => :album scope :previous, lambda { |p,a| { :conditions => ["id < :id AND album_Id = :album ", { :id => p, :album => a } ], :limit => 1, :order => "id DESC"} } @@ -55,9 +54,6 @@ class Photo < ActiveRecord::Base 0 end - protected - - private @@ -65,20 +61,12 @@ class Photo < ActiveRecord::Base self.title = self.file.file.basename.titleize unless self.title end - def set_path - self.path = self.file.file.file.sub(File.expand_path(Rails.root.to_s + '/public/' + ENV['STORAGE_PATH'] + "/files" ) + "/","") unless self.path - end - - def ensure_file - #self.destroy if !File.exists?( APP_CONFIG[:photos_path] + self.path ) - end - def exif_read photo = MiniExiftool.new(self.file.file.file) self.longitude = photo.GPSLongitude if self.longitude.nil? self.latitude = photo.GPSLatitude if self.latitude.nil? self.title = photo.DocumentName if self.title.nil? - self.description = photo.ImageDescription if self.description.nil? || photo.ImageDescription != 'Exif_JPEG_PICTURE' + self.description = photo.ImageDescription if self.description.nil? && photo.ImageDescription != 'Exif_JPEG_PICTURE' self.tag_list = (self.tags.empty? ? "" : self.album.tag_list) + " " + (photo.Keywords.nil? ? "" : photo.Keywords.to_a.map { |tag| tag.gsub(" ", "_") }.join(" ")) end