Added rake task for auto create of upcoming workgroup tasks (weekly tasks).

This commit is contained in:
Benjamin Meichsner 2009-08-11 17:17:18 +02:00
parent 7e2506baa2
commit d8cdbe4abb
6 changed files with 39 additions and 9 deletions

View file

@ -39,6 +39,19 @@ namespace :foodsoft do
end
end
desc "Create upcoming workgroups tasks (next 3 to 7 weeks)"
task :create_upcoming_weekly_tasks => :environment do
workgroups = Workgroup.all :conditions => {:weekly_task => true}
for workgroup in workgroups
puts "Create weekly tasks for #{workgroup.name}"
workgroup.next_weekly_tasks(8)[3..7].each do |date|
unless workgroup.tasks.exists?({:due_date => date, :weekly => true})
workgroup.tasks.create(workgroup.task_attributes(date))
end
end
end
end
desc "Notify users of finished orders"
task :notify_order_finished => :environment do
order = Order.find(ENV["ORDER_ID"])