Send warn messages for unassigned tasks 7 days before due date.

This commit is contained in:
Benjamin Meichsner 2009-08-12 21:47:07 +02:00
parent 83e741c1af
commit 332fc831c8

View file

@ -55,7 +55,7 @@ namespace :foodsoft do
desc "Notify workgroup of upcoming weekly task" desc "Notify workgroup of upcoming weekly task"
task :notify_users_of_weekly_task => :environment do task :notify_users_of_weekly_task => :environment do
for workgroup in Workgroup.all for workgroup in Workgroup.all
for task in workgroup.tasks.all(:conditions => ["due_date = ?", 4.days.from_now.to_date]) for task in workgroup.tasks.all(:conditions => ["due_date = ?", 7.days.from_now.to_date])
unless task.enough_users_assigned? unless task.enough_users_assigned?
puts "Notify workgroup: #{workgroup.name} for task #{task.name}" puts "Notify workgroup: #{workgroup.name} for task #{task.name}"
for user in workgroup.users.collect { |u| u if u.settings['messages.sendAsEmail'] == "1" && !u.email.blank? } for user in workgroup.users.collect { |u| u if u.settings['messages.sendAsEmail'] == "1" && !u.email.blank? }