Added rake task to notify workgroup members if not enough users assigned an upcoming task.

This commit is contained in:
Benjamin Meichsner 2009-08-11 18:10:14 +02:00
parent d8cdbe4abb
commit 49be55238b
4 changed files with 35 additions and 3 deletions

View File

@ -67,6 +67,13 @@ class Mailer < ActionMailer::Base
body :user => user, :message => message
end
def not_enough_users_assigned(task,user)
prepare_system_message(user)
subject "[#{Foodsoft.config[:name]}] #{task.name} braucht noch Leute!"
body :task => task, :user => user,
:task_url => File.join(Foodsoft.config[:base_url], "tasks/workgroup", task.workgroup_id.to_s)
end
protected
def prepare_system_message(recipient)

View File

@ -54,8 +54,8 @@ class Workgroup < Group
# now generate the Array
nextTasks = Array.new
number.times do
nextTasks << nextTask
nextTask = 1.week.from_now(nextTask).to_date
nextTasks << nextTask.to_date
nextTask = 1.week.from_now(nextTask)
end
return nextTasks
end
@ -69,5 +69,5 @@ class Workgroup < Group
:weekly => true
}
end
end

View File

@ -0,0 +1,11 @@
Liebe(r) <%= @user.first_name %>,
Der Job <%= @task.name -%> Deiner Arbeitsgruppe ist am <%= @task.due_date.strftime("%d. %b") -%> fällig
und es fehlen noch Mitstreiterinnen!
Sofern Du Dich noch nicht für diese Aufgabe eingetragen hast ist das jetzt die Chance:
<%= @task_url %>
--
Deine Aufgaben: <%= Foodsoft.config[:base_url] %>/home/tasks

View File

@ -52,6 +52,20 @@ namespace :foodsoft do
end
end
desc "Notify workgroup of upcoming weekly task"
task :notify_users_of_weekly_task => :environment do
for workgroup in Workgroup.all
for task in workgroup.tasks.all(:conditions => ["due_date = ?", 4.days.from_now.to_date])
unless task.enough_users_assigned?
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? }
Mailer.deliver_not_enough_users_assigned(task, user)
end
end
end
end
end
desc "Notify users of finished orders"
task :notify_order_finished => :environment do
order = Order.find(ENV["ORDER_ID"])