Commit 22ec463764f7fe2b6cf3003450c5eabe2c122d5f
1 parent
ed2b53cd
Exists in
master
and in
4 other branches
rake task to add all users to all projects
Showing
1 changed file
with
16 additions
and
0 deletions
Show diff stats
... | ... | @@ -0,0 +1,16 @@ |
1 | +desc "Add all users to all projects, system administratos are added as masters" | |
2 | +task :add_users_to_project_teams => :environment do |t, args| | |
3 | + users = User.find_all_by_admin(false, :select => 'id').map(&:id) | |
4 | + admins = User.find_all_by_admin(true, :select => 'id').map(&:id) | |
5 | + | |
6 | + users.each do |user| | |
7 | + puts "#{user}" | |
8 | + end | |
9 | + | |
10 | + Project.all.each do |project| | |
11 | + puts "Importing #{users.length} users into #{project.path}" | |
12 | + UsersProject.bulk_import(project, users, UsersProject::DEVELOPER) | |
13 | + puts "Importing #{admins.length} admins into #{project.path}" | |
14 | + UsersProject.bulk_import(project, admins, UsersProject::MASTER) | |
15 | + end | |
16 | +end | ... | ... |