mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-02-05 07:01:03 -05:00
Merge branch 'dev' into awesomecode-style/andor-8234
This commit is contained in:
@@ -82,6 +82,7 @@ submit the change with your pull request.
|
||||
- Harry Brodsky / [hbrodsk1](https://github.com/hbrodsk1)
|
||||
- Jeff Kingswood / [ancyentmariner](https://github.com/ancyentmariner)
|
||||
- Logan Gingerich / [logangingerich](https://github.com/logangingerich)
|
||||
- Mark Taffman / [mftaff](https://github.com/mftaff)
|
||||
|
||||
## Bots
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ class PhotosController < ApplicationController
|
||||
photo = Photo.find_by(flickr_photo_id: flickr_photo_id_param)
|
||||
photo ||= Photo.new(photo_params)
|
||||
photo.owner_id = current_member.id
|
||||
photo.set_flickr_metadata
|
||||
photo.set_flickr_metadata!
|
||||
photo
|
||||
end
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ class PlantingsController < ApplicationController
|
||||
@planting = Planting.includes(:owner, :crop, :garden, :photos)
|
||||
.friendly
|
||||
.find(params[:id])
|
||||
@photos = @planting.photos.order(created_at: :desc).includes(:owner).paginate(page: params[:page])
|
||||
@photos = @planting.photos.order(date_taken: :desc).includes(:owner).paginate(page: params[:page])
|
||||
respond_with @planting
|
||||
end
|
||||
|
||||
|
||||
@@ -27,7 +27,8 @@ class Photo < ActiveRecord::Base
|
||||
license_url: license.url,
|
||||
thumbnail_url: FlickRaw.url_q(info),
|
||||
fullsize_url: FlickRaw.url_z(info),
|
||||
link_url: FlickRaw.url_photopage(info)
|
||||
link_url: FlickRaw.url_photopage(info),
|
||||
date_taken: info.dates.taken
|
||||
}
|
||||
end
|
||||
|
||||
@@ -49,7 +50,11 @@ class Photo < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def set_flickr_metadata
|
||||
def set_flickr_metadata!
|
||||
update_attributes(flickr_metadata)
|
||||
end
|
||||
|
||||
def to_s
|
||||
"#{title} by #{owner.login_name}"
|
||||
end
|
||||
end
|
||||
|
||||
20
db/migrate/20180118112809_add_datetaken_to_photos.rb
Normal file
20
db/migrate/20180118112809_add_datetaken_to_photos.rb
Normal file
@@ -0,0 +1,20 @@
|
||||
class AddDatetakenToPhotos < ActiveRecord::Migration
|
||||
def up
|
||||
add_column :photos, :date_taken, :datetime
|
||||
update_flickr_metadata
|
||||
end
|
||||
|
||||
def down
|
||||
add_column :photos, :date_taken
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def update_flickr_metadata
|
||||
# Fetch from flickr, the photos updated the longest ago will be fetched first
|
||||
Photo.all.order(:updated_at).each do |photo|
|
||||
say "Fetch flickr data for #{photo}"
|
||||
photo.set_flickr_metadata!
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20171129041341) do
|
||||
ActiveRecord::Schema.define(version: 20180118112809) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
@@ -405,6 +405,7 @@ ActiveRecord::Schema.define(version: 20171129041341) do
|
||||
t.string "license_url"
|
||||
t.string "link_url", null: false
|
||||
t.string "flickr_photo_id"
|
||||
t.datetime "date_taken"
|
||||
end
|
||||
|
||||
create_table "photos_plantings", id: false, force: :cascade do |t|
|
||||
|
||||
Reference in New Issue
Block a user