Rename add_user_to_project_teams to gitlab:import:user_to_projects

Rename add_users_to_project_teams to gitlab:import:all_users_to_all_projects
This commit is contained in:
Riyad Preukschas 2012-12-20 20:05:01 +01:00
parent c9bf2bb288
commit 1acff973c8
3 changed files with 26 additions and 22 deletions

View file

@ -1,7 +1,7 @@
### Add user to as a developer to all projects
```
bundle exec rake add_user_to_project_teams[username@domain.tld]
bundle exec rake gitlab:import:user_to_projects[username@domain.tld]
```
@ -12,5 +12,5 @@ Notes:
* admin users are added as masters
```
bundle exec rake add_users_to_project_teams
bundle exec rake gitlab:import:all_users_to_all_projects
```

View file

@ -1,20 +0,0 @@
desc "Add all users to all projects (admin users are added as masters)"
task :add_users_to_project_teams => :environment do |t, args|
user_ids = User.where(:admin => false).pluck(:id)
admin_ids = User.where(:admin => true).pluck(:id)
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)
end
end
desc "Add user to as a developer to all projects"
task :add_user_to_project_teams, [:email] => :environment do |t, args|
user = User.find_by_email args.email
project_ids = Project.pluck(:id)
UsersProject.user_bulk_import(user, project_ids, UsersProject::DEVELOPER)
end

View file

@ -0,0 +1,24 @@
namespace :gitlab do
namespace :import do
desc "GITLAB | Add all users to all projects (admin users are added as masters)"
task :all_users_to_all_projects => :environment do |t, args|
user_ids = User.where(:admin => false).pluck(:id)
admin_ids = User.where(:admin => true).pluck(:id)
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)
end
end
desc "GITLAB | Add a specific user to all projects (as a developer)"
task :user_to_projects, [:email] => :environment do |t, args|
user = User.find_by_email args.email
project_ids = Project.pluck(:id)
UsersProject.user_bulk_import(user, project_ids, UsersProject::DEVELOPER)
end
end
end