2012-09-26 13:18:10 +02:00
|
|
|
desc "Add all users to all projects (admin users are added as masters)"
|
2012-08-23 11:48:45 +02:00
|
|
|
task :add_users_to_project_teams => :environment do |t, args|
|
2012-09-26 13:18:10 +02:00
|
|
|
user_ids = User.where(:admin => false).pluck(:id)
|
|
|
|
admin_ids = User.where(:admin => true).pluck(:id)
|
2012-08-23 11:48:45 +02:00
|
|
|
|
2012-09-26 13:18:10 +02:00
|
|
|
Project.find_each do |project|
|
|
|
|
puts "Importing #{user_ids.size} users into #{project.code}"
|
|
|
|
UsersProject.bulk_import(project, user_ids, UsersProject::DEVELOPER)
|
|
|
|
puts "Importing #{admin_ids.size} admins into #{project.code}"
|
|
|
|
UsersProject.bulk_import(project, admin_ids, UsersProject::MASTER)
|
2012-08-23 11:48:45 +02:00
|
|
|
end
|
|
|
|
end
|
2012-08-23 11:48:55 +02:00
|
|
|
|
|
|
|
desc "Add user to as a developer to all projects"
|
|
|
|
task :add_user_to_project_teams, [:email] => :environment do |t, args|
|
2012-09-26 13:18:10 +02:00
|
|
|
user = User.find_by_email args.email
|
|
|
|
project_ids = Project.pluck(:id)
|
2012-08-23 11:48:55 +02:00
|
|
|
|
2012-09-26 13:18:10 +02:00
|
|
|
UsersProject.user_bulk_import(user, project_ids, UsersProject::DEVELOPER)
|
2012-08-23 11:48:55 +02:00
|
|
|
end
|