Feature implemented
This commit is contained in:
parent
012d62b198
commit
fd0aca1225
5 changed files with 58 additions and 3 deletions
|
@ -21,6 +21,22 @@ class UsersProject < ActiveRecord::Base
|
|||
delegate :name, :email, to: :user, prefix: true
|
||||
|
||||
class << self
|
||||
def import_team(source_project, target_project)
|
||||
UsersProject.transaction do
|
||||
team = source_project.users_projects.all
|
||||
|
||||
team.each do |tm|
|
||||
# Skip if user already present in team
|
||||
next if target_project.users.include?(tm.user)
|
||||
|
||||
new_tm = tm.dup
|
||||
new_tm.id = nil
|
||||
new_tm.project_id = target_project.id
|
||||
new_tm.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def bulk_delete(project, user_ids)
|
||||
UsersProject.transaction do
|
||||
UsersProject.where(:user_id => user_ids, :project_id => project.id).each do |users_project|
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue