Commit 22ec463764f7fe2b6cf3003450c5eabe2c122d5f

Authored by Seif Attar
1 parent ed2b53cd

rake task to add all users to all projects

Showing 1 changed file with 16 additions and 0 deletions   Show diff stats
lib/tasks/bulk_add_permission.rake 0 → 100644
... ... @@ -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
... ...