2009-01-06 11:49:19 +01:00
|
|
|
# put in here all foodsoft tasks
|
|
|
|
# => :environment loads the environment an gives easy access to the application
|
|
|
|
|
|
|
|
namespace :foodsoft do
|
|
|
|
|
2009-02-01 20:56:23 +01:00
|
|
|
# "rake foodsoft:create_admin"
|
|
|
|
desc "creates Administrators-group and admin-user"
|
|
|
|
task :create_admin => :environment do
|
|
|
|
puts "Create Workgroup 'Administators'"
|
|
|
|
administrators = Workgroup.create(
|
|
|
|
:name => "Administrators",
|
|
|
|
:description => "System administrators.",
|
|
|
|
:role_admin => true,
|
|
|
|
:role_finance => true,
|
|
|
|
:role_article_meta => true,
|
|
|
|
:role_suppliers => true,
|
|
|
|
:role_orders => true
|
|
|
|
)
|
|
|
|
|
|
|
|
puts "Create User 'admin' with password 'secret'"
|
|
|
|
admin = User.create(:nick => "admin", :first_name => "Anton", :last_name => "Administrator",
|
|
|
|
:email => "admin@foo.test", :password => "secret")
|
|
|
|
|
|
|
|
puts "Joining 'admin' user to 'Administrators' group"
|
|
|
|
Membership.create(:group => administrators, :user => admin)
|
|
|
|
end
|
2009-02-10 15:07:47 +01:00
|
|
|
|
|
|
|
desc "Notify users of upcoming tasks"
|
|
|
|
task :notify_upcoming_tasks => :environment do
|
|
|
|
tasks = Task.find :all, :conditions => ["done = ? AND due_date = ?", false, 1.day.from_now.to_date]
|
|
|
|
for task in tasks
|
|
|
|
puts "Send notifications for #{task.name} to .."
|
|
|
|
for user in task.users
|
|
|
|
if user.settings['notify.upcoming_tasks'] == 1
|
|
|
|
puts "#{user.email}.."
|
2009-02-18 01:06:35 +01:00
|
|
|
Mailer.deliver_upcoming_tasks(user, task)
|
2009-02-10 15:07:47 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2009-01-06 11:49:19 +01:00
|
|
|
end
|