diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-02-12 11:40:40 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-02-12 11:40:40 +0400 |
commit | 168e0341a30bccdb481591f939bac1c0d751a8c0 (patch) | |
tree | 20d4cccac11a5461eba64a63b7d6f3f86d3fca0c /lib | |
parent | 5b0aa252ad052d0c1f1d9699b62271c40935d5cd (diff) | |
parent | 17105038caf237687ad0fc9f34bf5f368d0cc8a5 (diff) |
Merge pull request #5520 from gabetax/rake_group_bulk_add_permissions
add rake gitlab:import: all_users_to_all_groups and user_to_groups
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tasks/gitlab/bulk_add_permission.rake | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/tasks/gitlab/bulk_add_permission.rake b/lib/tasks/gitlab/bulk_add_permission.rake index 612a9ba93a8..0e1a3d071e9 100644 --- a/lib/tasks/gitlab/bulk_add_permission.rake +++ b/lib/tasks/gitlab/bulk_add_permission.rake @@ -20,5 +20,29 @@ namespace :gitlab do puts "Importing #{user.email} users into #{project_ids.size} projects" UsersProject.add_users_into_projects(project_ids, Array.wrap(user.id), UsersProject::DEVELOPER) end + + desc "GITLAB | Add all users to all groups (admin users are added as owners)" + task all_users_to_all_groups: :environment do |t, args| + user_ids = User.where(admin: false).pluck(:id) + admin_ids = User.where(admin: true).pluck(:id) + groups = Group.all + + puts "Importing #{user_ids.size} users into #{groups.size} groups" + puts "Importing #{admin_ids.size} admins into #{groups.size} groups" + groups.each do |group| + group.add_users(user_ids, UsersGroup::DEVELOPER) + group.add_users(admin_ids, UsersGroup::OWNER) + end + end + + desc "GITLAB | Add a specific user to all groups (as a developer)" + task :user_to_groups, [:email] => :environment do |t, args| + user = User.find_by_email args.email + groups = Group.all + puts "Importing #{user.email} users into #{groups.size} groups" + groups.each do |group| + group.add_users(Array.wrap(user.id), UsersGroup::DEVELOPER) + end + end end end |