Commit 2e836fa4288253bad9eb999c53103ac5f6581907
Exists in
master
and in
4 other branches
Merge pull request #1274 from wiggle/bulk_permissions_tasks
Rake tasks to assign permissions to users
Showing
1 changed file
with
26 additions
and
0 deletions
Show diff stats
... | ... | @@ -0,0 +1,26 @@ |
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 | |
17 | + | |
18 | +desc "Add user to as a developer to all projects" | |
19 | +task :add_user_to_project_teams, [:email] => :environment do |t, args| | |
20 | + user_email = args.email | |
21 | + user = User.find_by_email(user_email) | |
22 | + | |
23 | + project_ids = Project.all.map(&:id) | |
24 | + | |
25 | + UsersProject.user_bulk_import(user,project_ids,UsersProject::DEVELOPER) | |
26 | +end | ... | ... |