bulk access roles update/deletion added
This commit is contained in:
parent
3d3c6674fb
commit
2dc0519277
2 changed files with 30 additions and 0 deletions
|
@ -20,6 +20,23 @@ class UsersProject < ActiveRecord::Base
|
|||
|
||||
delegate :name, :email, to: :user, prefix: true
|
||||
|
||||
def self.bulk_delete(project, user_ids)
|
||||
UsersProject.transaction do
|
||||
UsersProject.where(:user_id => user_ids, :project_id => project.id).each do |users_project|
|
||||
users_project.delete
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.bulk_update(project, user_ids, project_access)
|
||||
UsersProject.transaction do
|
||||
UsersProject.where(:user_id => user_ids, :project_id => project.id).each do |users_project|
|
||||
users_project.project_access = project_access
|
||||
users_project.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.bulk_import(project, user_ids, project_access)
|
||||
UsersProject.transaction do
|
||||
user_ids.each do |user_id|
|
||||
|
|
|
@ -36,4 +36,17 @@ module Team
|
|||
UsersProject.bulk_import(self, users_ids, access_role)
|
||||
self.update_repository
|
||||
end
|
||||
|
||||
# Update multiple project users
|
||||
# to same access role by user ids
|
||||
def update_users_ids_to_role(users_ids, access_role)
|
||||
UsersProject.bulk_update(self, users_ids, access_role)
|
||||
self.update_repository
|
||||
end
|
||||
|
||||
# Delete multiple users from project by user ids
|
||||
def delete_users_by_ids(users_ids)
|
||||
UsersProject.bulk_delete(self, users_ids)
|
||||
self.update_repository
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue