debian-mirror-gitlab/lib/tasks/gitlab/user_management.rake

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

16 lines
697 B
Ruby
Raw Normal View History

2021-03-11 19:13:27 +05:30
# frozen_string_literal: true
2021-02-22 17:27:13 +05:30
namespace :gitlab do
namespace :user_management do
desc "GitLab | User management | Update all users of a group with personal project limit to 0 and can_create_group to false"
task :disable_project_and_group_creation, [:group_id] => :environment do |t, args|
group = Group.find(args.group_id)
result = User.where(id: group.direct_and_indirect_users_with_inactive.select(:id)).update_all(projects_limit: 0, can_create_group: false)
ids_count = group.direct_and_indirect_users_with_inactive.count
puts "Done".color(:green) if result == ids_count
puts "Something went wrong".color(:red) if result != ids_count
end
end
end