Navigation Menu

Skip to content
This repository has been archived by the owner on Mar 27, 2022. It is now read-only.

Commit

Permalink
Task to export photo files by site.
Browse files Browse the repository at this point in the history
  • Loading branch information
seven1m committed Dec 13, 2011
1 parent f9c1bd3 commit eabb21c
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions lib/tasks/export.rake
Expand Up @@ -75,6 +75,32 @@ namespace :onebody do

end

desc 'Export OneBody photos for particular SITE_ID, save to OUT_PATH'
task :photos => :environment do
require 'fileutils'
Site.current = site = Site.find(ENV['SITE_ID'])
[Family, Group, Person, Picture].each do |model|
plural = model.name.pluralize.downcase
out_path = File.join(ENV['OUT_PATH'], plural, 'photos')
FileUtils.mkdir_p(out_path)
model.where('photo_file_name is not null').order(:id).find_each do |record|
puts "#{model.name} #{record.id}"
system("cp -r public/system/production/#{plural}/photos/#{record.id} #{out_path}/#{record.id}")
end
end
out_path = File.join(ENV['OUT_PATH'], 'attachments', 'files')
FileUtils.mkdir_p(out_path)
Attachment.where('file_file_name is not null').order(:id).find_each do |record|
puts "Attachment #{record.id}"
system("cp -r public/system/production/attachments/files/#{record.id} #{out_path}/#{record.id}")
end
out_path = File.join(ENV['OUT_PATH'], 'sites', 'logos')
FileUtils.mkdir_p(out_path)
if Site.current.logo.exists?
system("cp -r public/system/production/sites/logos/#{Site.current.id} #{out_path}/#{Site.current.id}")
end
end

end

end

0 comments on commit eabb21c

Please sign in to comment.