add processed to post, which is set to default false for photos

This commit is contained in:
maxwell 2011-03-18 18:51:53 -07:00
parent 91a96adb4b
commit 5aa969559c
4 changed files with 18 additions and 3 deletions

View file

@ -33,12 +33,16 @@ class Photo < Post
photo = super(params)
image_file = params.delete(:user_file)
photo.random_string = gen_random_string(10)
photo.processed = false
photo.image.store! image_file
photo.update_photo_remote_path
photo
end
def not_processed?
!self.processed
end
def update_photo_remote_path
unless self.image.url.match(/^https?:\/\//)
pod_url = AppConfig[:pod_url].dup
@ -66,7 +70,7 @@ class Photo < Post
end
def url(name = nil)
if self.image.path.include? '.gif'
if self.not_processed? || self.image.path.include? '.gif'
image.url
elsif remote_photo_path
name = name.to_s + '_' if name

View file

@ -39,6 +39,7 @@ class ImageUploader < CarrierWave::Uploader::Base
end
self.recreate_versions!
self.model.processed = true
self.model.update_photo_remote_path
self.model.save
else

View file

@ -0,0 +1,9 @@
class AddProcessedToPost < ActiveRecord::Migration
def self.up
add_column(:posts, :processed, :boolean, :default => true)
end
def self.down
remove_column(:posts, :processed)
end
end

View file

@ -10,7 +10,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20110318012008) do
ActiveRecord::Schema.define(:version => 20110319005509) do
create_table "aspect_memberships", :force => true do |t|
t.integer "aspect_id", :null => false
@ -210,6 +210,7 @@ ActiveRecord::Schema.define(:version => 20110318012008) do
t.datetime "created_at"
t.datetime "updated_at"
t.string "mongo_id"
t.boolean "processed", :default => true
end
add_index "posts", ["author_id"], :name => "index_posts_on_person_id"